xardao 1.4.3 → 1.6.0
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/db_instances/mariadb +5 -0
- package/db_instances/mssql +8 -0
- package/db_instances/pg +5 -0
- package/doc/gen-doc.js +88 -0
- package/lib/common.js +17 -16
- package/lib/crud-adapter.js +4 -16
- package/lib/driver_mariadb.js +9 -15
- package/lib/driver_mssql.js +24 -21
- package/lib/driver_pgsql.js +12 -15
- package/lib/{driver-snowflake.js → driver_snowflake.js} +8 -18
- package/lib/driver_sqlite3.js +17 -23
- package/lib/esnext.js +2 -4
- package/lib/import-sync.cjs +6 -0
- package/lib/xardao.js +22 -25
- package/package.json +5 -4
- package/snowflake.log +44 -0
package/db_instances/pg
ADDED
package/doc/gen-doc.js
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
<<<<<<< HEAD
|
|
2
|
+
|
|
3
|
+
import * as mo from '../lib/driver_sqlite3.js'
|
|
4
|
+
=======
|
|
5
|
+
const mo = require("../lib/driver_mssql")
|
|
6
|
+
>>>>>>> b6c32ed02ef7499b64ccdebb5fa8ddf6b31071e8
|
|
7
|
+
|
|
8
|
+
function functionInfo(funcOrClass) {
|
|
9
|
+
if ( typeof funcOrClass === 'function' ) {
|
|
10
|
+
let source = Function.prototype.toString.call(funcOrClass)
|
|
11
|
+
let typeName = /^class\s/.test(source) ? "class" : "function"
|
|
12
|
+
let e = source.indexOf("{")
|
|
13
|
+
let signature = ""
|
|
14
|
+
if ( e >= 0 ) {
|
|
15
|
+
signature = source.substr(0, e)
|
|
16
|
+
}
|
|
17
|
+
return { name: funcOrClass.name, typeName: typeName, signature: signature }
|
|
18
|
+
} else {
|
|
19
|
+
return { name: funcOrClass.name, typename: typeof funcOrClass, signature: funcOrClass.name}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function documentNameSpace(mod, namespace) {
|
|
24
|
+
namespace = namespace || ""
|
|
25
|
+
|
|
26
|
+
if ( namespace == "" ) console.log ("Module")
|
|
27
|
+
else console.log ("Namespace " + namespace)
|
|
28
|
+
|
|
29
|
+
for (let f in mod ) {
|
|
30
|
+
if ( mod[f] instanceof Function ) {
|
|
31
|
+
let fi = functionInfo(mod[f])
|
|
32
|
+
if (fi.typeName == "class") {
|
|
33
|
+
console.log(" " + fi.signature)
|
|
34
|
+
let cls = mod[f]
|
|
35
|
+
let excludeProp = Object.getOwnPropertyNames(Object)
|
|
36
|
+
<<<<<<< HEAD
|
|
37
|
+
for (let m of Object.getOwnPropertyNames( cls ).filter (x => x!="constructor")) {
|
|
38
|
+
=======
|
|
39
|
+
for (m of Object.getOwnPropertyNames( cls ).filter (x => x!="constructor")) {
|
|
40
|
+
>>>>>>> b6c32ed02ef7499b64ccdebb5fa8ddf6b31071e8
|
|
41
|
+
if (excludeProp.indexOf(m) == -1 ) {
|
|
42
|
+
let mi = functionInfo(cls[m])
|
|
43
|
+
console.log(" static " + mi.signature)
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
let clsProto = mod[f].prototype
|
|
47
|
+
<<<<<<< HEAD
|
|
48
|
+
for (let m of Object.getOwnPropertyNames( clsProto ).filter (x => x!="constructor")) {
|
|
49
|
+
=======
|
|
50
|
+
for (m of Object.getOwnPropertyNames( clsProto ).filter (x => x!="constructor")) {
|
|
51
|
+
>>>>>>> b6c32ed02ef7499b64ccdebb5fa8ddf6b31071e8
|
|
52
|
+
let mi = functionInfo(clsProto[m])
|
|
53
|
+
console.log(" " + mi.signature)
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
console.log("")
|
|
59
|
+
|
|
60
|
+
for (let f in mod ) {
|
|
61
|
+
if ( mod[f] instanceof Function ) {
|
|
62
|
+
let fi = functionInfo(mod[f])
|
|
63
|
+
if (fi.typeName != "class") {
|
|
64
|
+
console.log(" " + fi.signature)
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
console.log("")
|
|
69
|
+
|
|
70
|
+
for (let f in mod ) {
|
|
71
|
+
if (typeof mod[f] =="string") {
|
|
72
|
+
console.log(` ${f} = "${mod[f]}"`)
|
|
73
|
+
} else if (typeof(mod[f]) != "function" && typeof(mod[f]) != "object") {
|
|
74
|
+
console.log(` ${f} = ${mod[f]}`)
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
console.log("")
|
|
79
|
+
for (let f in mod ) {
|
|
80
|
+
if ( typeof(mod[f]) == "object") {
|
|
81
|
+
let ns = namespace=="" ? f : namespace + "." + f
|
|
82
|
+
documentNameSpace(mod[f], ns )
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
documentNameSpace(mo)
|
|
88
|
+
|
package/lib/common.js
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
/********************************************************************************
|
|
2
|
-
*
|
|
2
|
+
* common.js
|
|
3
3
|
* Common elements in xardao implementation.
|
|
4
4
|
*
|
|
5
5
|
* Author : Stephane Potelle
|
|
6
6
|
* Email : stephane.potelle@gmail.com
|
|
7
7
|
********************************************************************************/
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
export function isFunction(f) {
|
|
10
10
|
if (!f ) return false;
|
|
11
11
|
return (typeof(f)=='function');
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
export function then(f) {
|
|
15
15
|
if (isFunction(f)) setImmediate(f);
|
|
16
16
|
else throw new Error('"Parameter should be a function. Found '+ typeof(f));
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
export class Batch {
|
|
20
20
|
constructor(cn){
|
|
21
21
|
this.conn = cn;
|
|
22
22
|
this.statements=[];
|
|
@@ -34,7 +34,7 @@ exports.Batch = class {
|
|
|
34
34
|
|
|
35
35
|
// Common implementation of the "exec" functionality.
|
|
36
36
|
// Specific drivers may use their own version of it.
|
|
37
|
-
|
|
37
|
+
export function exec(cn,params, callback) {
|
|
38
38
|
let t=typeof(params)
|
|
39
39
|
if (Array.isArray(params)) cn.execMultiple(params, callback);
|
|
40
40
|
else if ( t == 'string' || t == 'object') cn.execSingle(params, callback);
|
|
@@ -43,7 +43,7 @@ exports.exec = function(cn,params, callback) {
|
|
|
43
43
|
|
|
44
44
|
// Common implementation of the "execMultiple" functionality.
|
|
45
45
|
// Specific drivers may use their own version of it.
|
|
46
|
-
|
|
46
|
+
export function execMultiple(cn, queries, callback) {
|
|
47
47
|
var i = 0;
|
|
48
48
|
loop();
|
|
49
49
|
|
|
@@ -60,7 +60,7 @@ exports.execMultiple = function(cn, queries, callback) {
|
|
|
60
60
|
|
|
61
61
|
// Common implementation of the "exec" functionality.
|
|
62
62
|
// Specific drivers may use their own version of it.
|
|
63
|
-
|
|
63
|
+
export function execCB(cn,params, callback) {
|
|
64
64
|
let t=typeof(params)
|
|
65
65
|
if (Array.isArray(params)) cn.execMultipleCB(params, callback);
|
|
66
66
|
else if ( t == 'string' || t == 'object') cn.execSingleCB(params, callback);
|
|
@@ -69,7 +69,7 @@ exports.execCB = function(cn,params, callback) {
|
|
|
69
69
|
|
|
70
70
|
// Common implementation of the "execMultiple" functionality.
|
|
71
71
|
// Specific drivers may use their own version of it.
|
|
72
|
-
|
|
72
|
+
export function execMultipleCB(cn, queries, callback) {
|
|
73
73
|
var i = 0;
|
|
74
74
|
loop();
|
|
75
75
|
|
|
@@ -88,7 +88,7 @@ exports.execMultipleCB = function(cn, queries, callback) {
|
|
|
88
88
|
|
|
89
89
|
// Base implementation of the "sqlParam" method.
|
|
90
90
|
// Specific drivers may use their own version of it.
|
|
91
|
-
|
|
91
|
+
export function sqlParam(cn,value) {
|
|
92
92
|
if ( value == undefined ) return 'null'
|
|
93
93
|
if ( typeof(value)=='number') { return value}
|
|
94
94
|
if ( typeof(value)=='boolean') { return value == null ? null : value ? 1 : 0 }
|
|
@@ -97,7 +97,7 @@ exports.sqlParam = function(cn,value) {
|
|
|
97
97
|
return 'null'
|
|
98
98
|
}
|
|
99
99
|
|
|
100
|
-
|
|
100
|
+
export function mergeParams_old(cn,sql, params) {
|
|
101
101
|
var keys = Object.keys(params);
|
|
102
102
|
var osql = sql;
|
|
103
103
|
for ( let i = 0; i< keys.length; i++) {
|
|
@@ -109,7 +109,7 @@ exports.mergeParams_old = function(cn,sql, params) {
|
|
|
109
109
|
|
|
110
110
|
// Base implementation of the "mergeParams" method.
|
|
111
111
|
// Specific drivers may use their own version of it.
|
|
112
|
-
|
|
112
|
+
export function mergeParams(cn,sql, params) {
|
|
113
113
|
let rt = []
|
|
114
114
|
let isql = sql
|
|
115
115
|
let uparams = {}
|
|
@@ -136,11 +136,12 @@ exports.mergeParams = function(cn,sql, params) {
|
|
|
136
136
|
|
|
137
137
|
// Base implementation of the "getRealSql" method.
|
|
138
138
|
// Specific drivers may use their own version of it.
|
|
139
|
-
|
|
139
|
+
export function getRealSql(cn,queryObject) {
|
|
140
140
|
var realSql;
|
|
141
|
-
|
|
141
|
+
|
|
142
142
|
if (typeof(queryObject)=="string") { realSql= queryObject; }
|
|
143
143
|
else {
|
|
144
|
+
if ( queryObject.params == undefined ) queryObject.params = {}
|
|
144
145
|
if (queryObject.params) realSql = cn.mergeParams(queryObject.sql, queryObject.params);
|
|
145
146
|
}
|
|
146
147
|
return realSql;
|
|
@@ -148,7 +149,7 @@ exports.getRealSql = function(cn,queryObject) {
|
|
|
148
149
|
|
|
149
150
|
// Base implementation of the "sqlDate" method.
|
|
150
151
|
// Specific drivers may use their own version of it.
|
|
151
|
-
|
|
152
|
+
export function sqlDate(cn,d) {
|
|
152
153
|
function fixedInt(n, dig) {
|
|
153
154
|
var s = '' + n;
|
|
154
155
|
if (s.length < dig ) s = '0'.repeat(dig-s.length) + s;
|
|
@@ -219,7 +220,7 @@ function strToSnakeCase(fn) {
|
|
|
219
220
|
return ra.join('')
|
|
220
221
|
}
|
|
221
222
|
|
|
222
|
-
|
|
223
|
+
export function toCamelCase(o) {
|
|
223
224
|
if (o == undefined || o == null)
|
|
224
225
|
return o
|
|
225
226
|
else if (typeof(o) == "object") {
|
|
@@ -231,7 +232,7 @@ exports.toCamelCase = function toCamelCase(o) {
|
|
|
231
232
|
}
|
|
232
233
|
}
|
|
233
234
|
|
|
234
|
-
|
|
235
|
+
export function toSnakeCase(o) {
|
|
235
236
|
if (o == undefined || o == null)
|
|
236
237
|
return o
|
|
237
238
|
else if (typeof(o) == "object") {
|
package/lib/crud-adapter.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
var ESNext = require('./esnext');
|
|
2
1
|
|
|
3
|
-
|
|
2
|
+
import { ESNext } from './esnext.js'
|
|
3
|
+
|
|
4
|
+
export function createCRUDAdapter(conn, table, pk) {
|
|
4
5
|
return new CRUDAdapter(conn, table, pk)
|
|
5
6
|
}
|
|
6
7
|
|
|
7
|
-
class CRUDAdapter {
|
|
8
|
+
export class CRUDAdapter {
|
|
8
9
|
constructor (conn, table, pk) {
|
|
9
10
|
this.conn = conn
|
|
10
11
|
this.table = table
|
|
@@ -250,16 +251,3 @@ class CRUDAdapter {
|
|
|
250
251
|
|
|
251
252
|
}
|
|
252
253
|
|
|
253
|
-
module.exports.CRUDAdapter = CRUDAdapter
|
|
254
|
-
module.exports.createCRUDAdapter = createCRUDAdapter
|
|
255
|
-
|
|
256
|
-
/*
|
|
257
|
-
let qb = new CRUDAdapter(null, 'contact', 'Id')
|
|
258
|
-
qb.fields=['Id','Firstname', 'Lastname', 'Birthdate', 'Age']
|
|
259
|
-
|
|
260
|
-
console.log(JSON.stringify (qb.selectStatement(12)))
|
|
261
|
-
console.log(JSON.stringify (qb.insertStatement( { } )))
|
|
262
|
-
console.log(JSON.stringify (qb.insertStatement( { Id: 223, Firstname: 'John', Lastname: 'Doe'} )))
|
|
263
|
-
console.log(JSON.stringify (qb.updateStatement( { Id: 223, Firstname: 'John', Lastname: 'Doe'} )))
|
|
264
|
-
console.log(JSON.stringify (qb.deleteStatement( { Id: 12 })))
|
|
265
|
-
*/
|
package/lib/driver_mariadb.js
CHANGED
|
@@ -6,21 +6,14 @@
|
|
|
6
6
|
* Email : stephane.potelle@gmail.com
|
|
7
7
|
********************************************************************************/
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
process.exit(1)
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
var common = require ('./common.js');
|
|
18
|
-
var ESNext = require('./esnext');
|
|
9
|
+
import { importSync } from './import-sync.cjs'
|
|
10
|
+
const mysql=importSync('mysql') // We need this synchronous but the import will be done only once
|
|
11
|
+
import * as common from './common.js'
|
|
12
|
+
import { isFunction, then } from './common.js'
|
|
13
|
+
import { ESNext } from './esnext.js'
|
|
19
14
|
|
|
20
|
-
isFunction = common.isFunction;
|
|
21
|
-
then = common.then;
|
|
22
15
|
|
|
23
|
-
class Connection {
|
|
16
|
+
export class Connection {
|
|
24
17
|
constructor(connUrlInfo) {
|
|
25
18
|
this.debugMode = false;
|
|
26
19
|
this.lastInsertId = null;
|
|
@@ -69,7 +62,8 @@ class Connection {
|
|
|
69
62
|
host: this.connUrlInfo.hostname,
|
|
70
63
|
user: this.connUrlInfo.username,
|
|
71
64
|
password: this.connUrlInfo.password,
|
|
72
|
-
database: this.connUrlInfo.database
|
|
65
|
+
database: this.connUrlInfo.database,
|
|
66
|
+
port: this.connUrlInfo.port
|
|
73
67
|
}
|
|
74
68
|
this.db = new mysql.createConnection( conninfo )
|
|
75
69
|
}
|
|
@@ -318,5 +312,5 @@ class Connection {
|
|
|
318
312
|
|
|
319
313
|
}
|
|
320
314
|
|
|
321
|
-
|
|
315
|
+
|
|
322
316
|
|
package/lib/driver_mssql.js
CHANGED
|
@@ -6,21 +6,13 @@
|
|
|
6
6
|
* Email : stephane.potelle@gmail.com
|
|
7
7
|
********************************************************************************/
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
process.exit(1)
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
var common = require ('./common.js')
|
|
18
|
-
var ESNext = require('./esnext')
|
|
9
|
+
import { importSync } from './import-sync.cjs'
|
|
10
|
+
const mssql=importSync('tedious') // We need this synchronous but the import will be done only once
|
|
11
|
+
import * as common from './common.js'
|
|
12
|
+
import { isFunction, then } from './common.js'
|
|
13
|
+
import { ESNext } from './esnext.js'
|
|
19
14
|
|
|
20
|
-
|
|
21
|
-
then = common.then
|
|
22
|
-
|
|
23
|
-
class Connection {
|
|
15
|
+
export class Connection {
|
|
24
16
|
constructor(connUrlInfo) {
|
|
25
17
|
this.debugMode = false
|
|
26
18
|
this.lastInsertId = null
|
|
@@ -73,11 +65,22 @@ class Connection {
|
|
|
73
65
|
if (dbInfo) {
|
|
74
66
|
connInfo=dbInfo
|
|
75
67
|
} else {
|
|
76
|
-
connInfo= {
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
68
|
+
connInfo= {
|
|
69
|
+
server: this.connUrlInfo.hostname,
|
|
70
|
+
|
|
71
|
+
authentication: {
|
|
72
|
+
type: 'default',
|
|
73
|
+
options: {
|
|
74
|
+
userName: this.connUrlInfo.username,
|
|
75
|
+
password: this.connUrlInfo.password
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
options: {
|
|
79
|
+
port: (this.connUrlInfo.port || 1433) *1,
|
|
80
|
+
database: this.connUrlInfo.database || 'master',
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
if (this.connUrlInfo.port != '' ) connInfo.port= +this.connUrlInfo.port
|
|
81
84
|
for (let o in this.connUrlInfo.options ) {
|
|
82
85
|
let v=this.connUrlInfo.options[o]
|
|
83
86
|
|
|
@@ -87,7 +90,7 @@ class Connection {
|
|
|
87
90
|
else connInfo.options[o] = v
|
|
88
91
|
}
|
|
89
92
|
}
|
|
90
|
-
connInfo.options.validateBulkLoadParameters = connInfo.options.validateBulkLoadParameters
|
|
93
|
+
connInfo.options.validateBulkLoadParameters = connInfo.options.validateBulkLoadParameters || false
|
|
91
94
|
this.db = new mssql.Connection(connInfo)
|
|
92
95
|
this.db.on("error", function(err) {
|
|
93
96
|
me.debug('Connection',err)
|
|
@@ -362,5 +365,5 @@ class Connection {
|
|
|
362
365
|
|
|
363
366
|
}
|
|
364
367
|
|
|
365
|
-
|
|
368
|
+
|
|
366
369
|
|
package/lib/driver_pgsql.js
CHANGED
|
@@ -6,20 +6,14 @@
|
|
|
6
6
|
* Email : stephane.potelle@gmail.com
|
|
7
7
|
********************************************************************************/
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
process.exit(1)
|
|
15
|
-
}
|
|
16
|
-
var common = require ('./common.js');
|
|
17
|
-
var ESNext = require('./esnext');
|
|
9
|
+
import { importSync } from './import-sync.cjs'
|
|
10
|
+
const pg=importSync('pg') // We need this synchronous but the import will be done only once
|
|
11
|
+
import * as common from './common.js'
|
|
12
|
+
import { isFunction, then } from './common.js'
|
|
13
|
+
import { ESNext } from './esnext.js'
|
|
18
14
|
|
|
19
|
-
isFunction = common.isFunction;
|
|
20
|
-
then = common.then;
|
|
21
15
|
|
|
22
|
-
class Connection {
|
|
16
|
+
export class Connection {
|
|
23
17
|
constructor(connUrlInfo) {
|
|
24
18
|
this.debugMode = false;
|
|
25
19
|
this.lastInsertId = null;
|
|
@@ -69,7 +63,12 @@ class Connection {
|
|
|
69
63
|
if (dbInfo) {
|
|
70
64
|
connInfo=dbInfo
|
|
71
65
|
} else {
|
|
72
|
-
connInfo= {
|
|
66
|
+
connInfo= {
|
|
67
|
+
host: this.connUrlInfo.hostname,
|
|
68
|
+
port: ( this.connUrlInfo.port || 5432 ) * 1,
|
|
69
|
+
user: this.connUrlInfo.username,
|
|
70
|
+
password: this.connUrlInfo.password,
|
|
71
|
+
database: this.connUrlInfo.database }
|
|
73
72
|
}
|
|
74
73
|
|
|
75
74
|
this.db = new pg.Client(connInfo);
|
|
@@ -327,5 +326,3 @@ class Connection {
|
|
|
327
326
|
}
|
|
328
327
|
}
|
|
329
328
|
|
|
330
|
-
exports.Connection = Connection;
|
|
331
|
-
|
|
@@ -1,26 +1,18 @@
|
|
|
1
1
|
/********************************************************************************
|
|
2
|
-
*
|
|
3
|
-
*
|
|
2
|
+
* snowflake.js
|
|
3
|
+
* Snowflake xardao driver
|
|
4
4
|
*
|
|
5
5
|
* Author : Stephane Potelle
|
|
6
6
|
* Email : stephane.potelle@gmail.com
|
|
7
7
|
********************************************************************************/
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
process.exit(1)
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
var common = require ('./common.js');
|
|
18
|
-
var ESNext = require('./esnext');
|
|
19
|
-
|
|
20
|
-
isFunction = common.isFunction;
|
|
21
|
-
then = common.then;
|
|
9
|
+
import { importSync } from './import-sync.cjs'
|
|
10
|
+
const sf=importSync('snowflake-sdk') // We need this synchronous but the import will be done only once
|
|
11
|
+
import * as common from './common.js'
|
|
12
|
+
import { isFunction, then } from './common.js'
|
|
13
|
+
import { ESNext } from './esnext.js'
|
|
22
14
|
|
|
23
|
-
class Connection {
|
|
15
|
+
export class Connection {
|
|
24
16
|
constructor(connUrlInfo) {
|
|
25
17
|
this.debugMode = false;
|
|
26
18
|
this.lastInsertId = null;
|
|
@@ -356,5 +348,3 @@ class Connection {
|
|
|
356
348
|
|
|
357
349
|
}
|
|
358
350
|
|
|
359
|
-
exports.Connection = Connection;
|
|
360
|
-
|
package/lib/driver_sqlite3.js
CHANGED
|
@@ -6,21 +6,16 @@
|
|
|
6
6
|
* Email : stephane.potelle@gmail.com
|
|
7
7
|
********************************************************************************/
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
console.error("Please add module \"sqlite3\" to your package.json dependencies")
|
|
14
|
-
process.exit(1)
|
|
15
|
-
}
|
|
9
|
+
import { importSync } from './import-sync.cjs'
|
|
10
|
+
const sq3=importSync('sqlite3') // We need this synchronous but the import will be done only once
|
|
11
|
+
import * as common from './common.js'
|
|
12
|
+
import { ESNext } from './esnext.js'
|
|
16
13
|
|
|
17
|
-
var common = require ('./common.js');
|
|
18
|
-
var ESNext = require('./esnext');
|
|
19
14
|
|
|
20
|
-
isFunction = common.isFunction;
|
|
21
|
-
then = common.then;
|
|
15
|
+
const isFunction = common.isFunction;
|
|
16
|
+
const then = common.then;
|
|
22
17
|
|
|
23
|
-
class Connection {
|
|
18
|
+
export class Connection {
|
|
24
19
|
constructor(connUrlInfo) {
|
|
25
20
|
this.debugMode = false;
|
|
26
21
|
this.lastInsertId = null;
|
|
@@ -48,16 +43,16 @@ class Connection {
|
|
|
48
43
|
this.close = ESNext(this.closeCB, this)
|
|
49
44
|
}
|
|
50
45
|
|
|
51
|
-
open() {}
|
|
52
|
-
getObjects() {}
|
|
53
|
-
getSingleObject () {}
|
|
54
|
-
getList() {}
|
|
55
|
-
getKVList() {}
|
|
56
|
-
getScalar() {}
|
|
57
|
-
exec() {}
|
|
58
|
-
execSingle() {}
|
|
59
|
-
execMultiple() {}
|
|
60
|
-
readTableStructure() {}
|
|
46
|
+
open(pDbInfo) {}
|
|
47
|
+
getObjects(queryObject) {}
|
|
48
|
+
getSingleObject (queryObject) {}
|
|
49
|
+
getList(queryObject) {}
|
|
50
|
+
getKVList(queryObject) {}
|
|
51
|
+
getScalar(queryObject) {}
|
|
52
|
+
exec(queryObject) {}
|
|
53
|
+
execSingle(queryObject) {}
|
|
54
|
+
execMultiple(queryObjectArray) {}
|
|
55
|
+
readTableStructure(tableName) {}
|
|
61
56
|
close() {}
|
|
62
57
|
setNoCount() {}
|
|
63
58
|
|
|
@@ -331,5 +326,4 @@ class Connection {
|
|
|
331
326
|
|
|
332
327
|
}
|
|
333
328
|
|
|
334
|
-
exports.Connection = Connection;
|
|
335
329
|
|
package/lib/esnext.js
CHANGED
|
@@ -6,10 +6,9 @@
|
|
|
6
6
|
* Email : stephane.potelle@gmail.com
|
|
7
7
|
********************************************************************************/
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
import * as util from 'util'
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
function ESNext(f, obj) {
|
|
11
|
+
export function ESNext(f, obj) {
|
|
13
12
|
const fp = util.promisify(f)
|
|
14
13
|
return function(...args) {
|
|
15
14
|
if (typeof (args[args.length-1])=='function' && args.length == f.length) {
|
|
@@ -24,4 +23,3 @@ function ESNext(f, obj) {
|
|
|
24
23
|
}
|
|
25
24
|
|
|
26
25
|
|
|
27
|
-
module.exports = ESNext
|
package/lib/xardao.js
CHANGED
|
@@ -6,10 +6,11 @@
|
|
|
6
6
|
* Email : stephane.potelle@gmail.com
|
|
7
7
|
********************************************************************************/
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
import * as modCRUDAdapter from'./crud-adapter.js'
|
|
10
|
+
import { URL } from 'url'
|
|
11
|
+
import { importSync } from './import-sync.cjs'
|
|
11
12
|
|
|
12
|
-
|
|
13
|
+
export const CRUDAdapter = modCRUDAdapter.CRUDAdapter
|
|
13
14
|
|
|
14
15
|
function parseConnUrl(url) {
|
|
15
16
|
try {
|
|
@@ -36,8 +37,10 @@ function parseConnUrl(url) {
|
|
|
36
37
|
catch(e){ return undefined }
|
|
37
38
|
}
|
|
38
39
|
|
|
39
|
-
|
|
40
|
-
|
|
40
|
+
// Cache loaded drivers
|
|
41
|
+
var mariadbDriver, sqliteDriver, pgDriver, mssqlDriver, sfDriver
|
|
42
|
+
|
|
43
|
+
export function Connection(url) {
|
|
41
44
|
let driver
|
|
42
45
|
let connInfo = parseConnUrl(url)
|
|
43
46
|
if (connInfo) {
|
|
@@ -48,40 +51,40 @@ function Connection(url) {
|
|
|
48
51
|
|
|
49
52
|
try {
|
|
50
53
|
if (driver == 'mysql' || driver == 'mariadb') {
|
|
51
|
-
if (
|
|
52
|
-
let cn = new
|
|
54
|
+
if (mariadbDriver == undefined ) mariadbDriver = importSync('./driver_mariadb.js')
|
|
55
|
+
let cn = new mariadbDriver.Connection(connInfo)
|
|
53
56
|
cn.createCRUDAdapter = function(table, pk) {
|
|
54
57
|
return modCRUDAdapter.createCRUDAdapter(this, table, pk)
|
|
55
58
|
}
|
|
56
59
|
return cn
|
|
57
60
|
}
|
|
58
61
|
else if (driver == 'sqlite' || driver == 'sqlite3') {
|
|
59
|
-
if (
|
|
60
|
-
let cn = new
|
|
62
|
+
if (sqliteDriver == undefined ) sqliteDriver = importSync('./driver_sqlite3.js')
|
|
63
|
+
let cn = new sqliteDriver.Connection(connInfo)
|
|
61
64
|
cn.createCRUDAdapter = function(table, pk) {
|
|
62
65
|
return modCRUDAdapter.createCRUDAdapter(this, table, pk)
|
|
63
66
|
}
|
|
64
67
|
return cn
|
|
65
68
|
}
|
|
66
|
-
else if (driver == 'pg' || driver == 'pgsql' || driver == 'postgres') {
|
|
67
|
-
if (
|
|
68
|
-
let cn = new
|
|
69
|
+
else if (driver == 'pg' || driver == 'pgsql' || driver == 'postgres.js') {
|
|
70
|
+
if (pgDriver == undefined ) pgDriver = importSync('./driver_pgsql.js')
|
|
71
|
+
let cn = new pgDriver.Connection(connInfo)
|
|
69
72
|
cn.createCRUDAdapter = function(table, pk) {
|
|
70
73
|
return modCRUDAdapter.createCRUDAdapter(this, table, pk)
|
|
71
74
|
}
|
|
72
75
|
return cn
|
|
73
76
|
}
|
|
74
77
|
else if (driver == 'ms' || driver == 'mssql') {
|
|
75
|
-
|
|
76
|
-
|
|
78
|
+
if (mssqlDriver == undefined ) mssqlDriver = importSync('./driver_mssql.js')
|
|
79
|
+
let cn = new mssqlDriver.Connection(connInfo)
|
|
77
80
|
cn.createCRUDAdapter = function(table, pk) {
|
|
78
81
|
return modCRUDAdapter.createCRUDAdapter(this, table, pk)
|
|
79
82
|
}
|
|
80
83
|
return cn
|
|
81
84
|
}
|
|
82
85
|
else if (driver == 'sf' || driver == 'snowflake') {
|
|
83
|
-
if (
|
|
84
|
-
let cn = new
|
|
86
|
+
if (sfDriver == undefined ) sfDriver = importSync('./driver_snowflake.js')
|
|
87
|
+
let cn = new sfDriver.Connection(connInfo)
|
|
85
88
|
cn.createCRUDAdapter = function(table, pk) {
|
|
86
89
|
return modCRUDAdapter.createCRUDAdapter(this, table, pk)
|
|
87
90
|
}
|
|
@@ -96,14 +99,9 @@ function Connection(url) {
|
|
|
96
99
|
}
|
|
97
100
|
}
|
|
98
101
|
|
|
99
|
-
exports.Connection = Connection
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
exports.express = {}
|
|
103
|
-
exports.express.usingDBConnection = function usingDBConnection(connSpec, page ) {
|
|
104
|
-
|
|
105
|
-
|
|
106
102
|
|
|
103
|
+
export var express = {}
|
|
104
|
+
express.usingDBConnection = function usingDBConnection(connSpec, page ) {
|
|
107
105
|
return function(req, res, next) {
|
|
108
106
|
|
|
109
107
|
if (typeof(connSpec) == "object") connInfo = connSpec
|
|
@@ -152,7 +150,7 @@ exports.express.usingDBConnection = function usingDBConnection(connSpec, page )
|
|
|
152
150
|
}
|
|
153
151
|
}
|
|
154
152
|
|
|
155
|
-
|
|
153
|
+
express.connect = async function connect(config, req, res) {
|
|
156
154
|
let conn
|
|
157
155
|
let connUrlInfo = parseConnUrl(config)
|
|
158
156
|
try {
|
|
@@ -177,4 +175,3 @@ exports.express.connect = async function connect(config, req, res) {
|
|
|
177
175
|
}
|
|
178
176
|
}
|
|
179
177
|
|
|
180
|
-
module.exports.Connection = Connection
|
package/package.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "xardao",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.6.0",
|
|
4
|
+
"type": "module",
|
|
4
5
|
"description": "Common Relational Data Access library",
|
|
5
6
|
"main": "./lib/xardao.js",
|
|
6
7
|
"scripts": {
|
|
@@ -12,11 +13,10 @@
|
|
|
12
13
|
},
|
|
13
14
|
"author": "Stephane Potelle",
|
|
14
15
|
"license": "MIT",
|
|
15
|
-
"dependencies": {
|
|
16
|
-
},
|
|
16
|
+
"dependencies": {},
|
|
17
17
|
"repository": {
|
|
18
18
|
"type": "git",
|
|
19
|
-
"url": "https://
|
|
19
|
+
"url": "git+https://github.com/stefpo/xardao.git"
|
|
20
20
|
},
|
|
21
21
|
"keywords": [
|
|
22
22
|
"database",
|
|
@@ -28,6 +28,7 @@
|
|
|
28
28
|
"sqlite3",
|
|
29
29
|
"mssql",
|
|
30
30
|
"postgresql",
|
|
31
|
+
"snowflake",
|
|
31
32
|
"pg"
|
|
32
33
|
]
|
|
33
34
|
}
|
package/snowflake.log
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
{"level":"INFO","message":"[2:02:40.282 PM]: Creating new connection object"}
|
|
2
|
+
{"level":"INFO","message":"[2:02:40.296 PM]: Creating Connection[id: e248da83-f8c1-4953-8e3e-b0382bdf3fdc] with host: keysight.snowflakecomputing.com, account: keysight, accessUrl: https://keysight.snowflakecomputing.com, user: INFOLINE, role: undefined, database: PRODUCTION, schema: SALESFORCE_BASE_TABLES, warehouse: BI_WH, proxy was not configured, password is provided, region: undefined, authenticator: SNOWFLAKE, ocsp mode: FAIL_OPEN, os: win32, os version: 10.0.22631"}
|
|
3
|
+
{"level":"INFO","message":"[2:02:40.296 PM]: Connection[id: e248da83-f8c1-4953-8e3e-b0382bdf3fdc] additional details: passcode in password is provided, passcode is not provided, private key is not provided, application: undefined, client name: snowflake-sdk, client version: 2.1.0, retry timeout: 300, private key path: undefined, private key pass is not provided, client store temporary credential: false, browser response timeout: 120000"}
|
|
4
|
+
{"level":"INFO","message":"[2:02:40.297 PM]: Connection[id: e248da83-f8c1-4953-8e3e-b0382bdf3fdc] - connection object created successfully."}
|
|
5
|
+
{"level":"INFO","message":"[2:02:40.297 PM]: Connection[id: e248da83-f8c1-4953-8e3e-b0382bdf3fdc] - connecting. Associated Snowflake domain: GLOBAL"}
|
|
6
|
+
{"level":"INFO","message":"[2:02:40.299 PM]: Connection[id: e248da83-f8c1-4953-8e3e-b0382bdf3fdc] - authentication successful using: SNOWFLAKE"}
|
|
7
|
+
{"level":"INFO","message":"[2:02:40.300 PM]: Trying to initialize Easy Logging"}
|
|
8
|
+
{"level":"INFO","message":"[2:02:40.302 PM]: No client config detected."}
|
|
9
|
+
{"level":"INFO","message":"[2:02:40.303 PM]: No config file path found. Client config will not be used."}
|
|
10
|
+
{"level":"INFO","message":"[2:02:40.303 PM]: Easy Logging is disabled as no config has been found"}
|
|
11
|
+
{"level":"INFO","message":"[2:02:40.307 PM]: Connection[id: e248da83-f8c1-4953-8e3e-b0382bdf3fdc] - connected successfully after 9.306699999999978 milliseconds"}
|
|
12
|
+
{"level":"INFO","message":"[4:57:40.756 PM]: Creating new connection object"}
|
|
13
|
+
{"level":"INFO","message":"[4:57:40.776 PM]: Creating Connection[id: 3af408bb-609d-4c73-bc67-eb6037ddcf2b] with host: keysight.snowflakecomputing.com, account: keysight, accessUrl: https://keysight.snowflakecomputing.com, user: INFOLINE, role: undefined, database: PRODUCTION, schema: SALESFORCE_BASE_TABLES, warehouse: BI_WH, proxy was not configured, password is provided, region: undefined, authenticator: SNOWFLAKE, ocsp mode: FAIL_OPEN, os: win32, os version: 10.0.22631"}
|
|
14
|
+
{"level":"INFO","message":"[4:57:40.776 PM]: Connection[id: 3af408bb-609d-4c73-bc67-eb6037ddcf2b] additional details: passcode in password is provided, passcode is not provided, private key is not provided, application: undefined, client name: snowflake-sdk, client version: 2.3.1, retry timeout: 300, private key path: undefined, private key pass is not provided, client store temporary credential: false, browser response timeout: 120000"}
|
|
15
|
+
{"level":"INFO","message":"[4:57:40.777 PM]: Connection[id: 3af408bb-609d-4c73-bc67-eb6037ddcf2b] - connection object created successfully."}
|
|
16
|
+
{"level":"INFO","message":"[4:57:40.777 PM]: Connection[id: 3af408bb-609d-4c73-bc67-eb6037ddcf2b] - connecting. Associated Snowflake domain: GLOBAL"}
|
|
17
|
+
{"level":"INFO","message":"[4:57:40.778 PM]: Connection[id: 3af408bb-609d-4c73-bc67-eb6037ddcf2b] - authentication successful using: SNOWFLAKE"}
|
|
18
|
+
{"level":"INFO","message":"[4:57:40.778 PM]: Trying to initialize Easy Logging"}
|
|
19
|
+
{"level":"INFO","message":"[4:57:40.787 PM]: No client config detected."}
|
|
20
|
+
{"level":"INFO","message":"[4:57:40.788 PM]: No config file path found. Client config will not be used."}
|
|
21
|
+
{"level":"INFO","message":"[4:57:40.789 PM]: Easy Logging is disabled as no config has been found"}
|
|
22
|
+
{"level":"INFO","message":"[4:57:40.792 PM]: Connection[id: 3af408bb-609d-4c73-bc67-eb6037ddcf2b] - connected successfully after 15.26 milliseconds"}
|
|
23
|
+
{"level":"INFO","message":"[4:58:39.679 PM]: Creating new connection object"}
|
|
24
|
+
{"level":"INFO","message":"[4:58:39.692 PM]: Creating Connection[id: 2754e7d9-2b10-4219-b4fa-c6460939428e] with host: keysight.snowflakecomputing.com, account: keysight, accessUrl: https://keysight.snowflakecomputing.com, user: INFOLINE, role: undefined, database: PRODUCTION, schema: SALESFORCE_BASE_TABLES, warehouse: BI_WH, proxy was not configured, password is provided, region: undefined, authenticator: SNOWFLAKE, ocsp mode: FAIL_OPEN, os: win32, os version: 10.0.22631"}
|
|
25
|
+
{"level":"INFO","message":"[4:58:39.693 PM]: Connection[id: 2754e7d9-2b10-4219-b4fa-c6460939428e] additional details: passcode in password is provided, passcode is not provided, private key is not provided, application: undefined, client name: snowflake-sdk, client version: 2.3.1, retry timeout: 300, private key path: undefined, private key pass is not provided, client store temporary credential: false, browser response timeout: 120000"}
|
|
26
|
+
{"level":"INFO","message":"[4:58:39.693 PM]: Connection[id: 2754e7d9-2b10-4219-b4fa-c6460939428e] - connection object created successfully."}
|
|
27
|
+
{"level":"INFO","message":"[4:58:39.694 PM]: Connection[id: 2754e7d9-2b10-4219-b4fa-c6460939428e] - connecting. Associated Snowflake domain: GLOBAL"}
|
|
28
|
+
{"level":"INFO","message":"[4:58:39.694 PM]: Connection[id: 2754e7d9-2b10-4219-b4fa-c6460939428e] - authentication successful using: SNOWFLAKE"}
|
|
29
|
+
{"level":"INFO","message":"[4:58:39.695 PM]: Trying to initialize Easy Logging"}
|
|
30
|
+
{"level":"INFO","message":"[4:58:39.700 PM]: No client config detected."}
|
|
31
|
+
{"level":"INFO","message":"[4:58:39.700 PM]: No config file path found. Client config will not be used."}
|
|
32
|
+
{"level":"INFO","message":"[4:58:39.701 PM]: Easy Logging is disabled as no config has been found"}
|
|
33
|
+
{"level":"INFO","message":"[4:58:39.704 PM]: Connection[id: 2754e7d9-2b10-4219-b4fa-c6460939428e] - connected successfully after 10.06 milliseconds"}
|
|
34
|
+
{"level":"INFO","message":"[4:59:29.596 PM]: Creating new connection object"}
|
|
35
|
+
{"level":"INFO","message":"[4:59:29.609 PM]: Creating Connection[id: 35097e4c-8231-4565-82f3-7c2d2640bdec] with host: keysight.snowflakecomputing.com, account: keysight, accessUrl: https://keysight.snowflakecomputing.com, user: INFOLINE, role: undefined, database: PRODUCTION, schema: SALESFORCE_BASE_TABLES, warehouse: BI_WH, proxy was not configured, password is provided, region: undefined, authenticator: SNOWFLAKE, ocsp mode: FAIL_OPEN, os: win32, os version: 10.0.22631"}
|
|
36
|
+
{"level":"INFO","message":"[4:59:29.609 PM]: Connection[id: 35097e4c-8231-4565-82f3-7c2d2640bdec] additional details: passcode in password is provided, passcode is not provided, private key is not provided, application: undefined, client name: snowflake-sdk, client version: 2.3.1, retry timeout: 300, private key path: undefined, private key pass is not provided, client store temporary credential: false, browser response timeout: 120000"}
|
|
37
|
+
{"level":"INFO","message":"[4:59:29.610 PM]: Connection[id: 35097e4c-8231-4565-82f3-7c2d2640bdec] - connection object created successfully."}
|
|
38
|
+
{"level":"INFO","message":"[4:59:29.610 PM]: Connection[id: 35097e4c-8231-4565-82f3-7c2d2640bdec] - connecting. Associated Snowflake domain: GLOBAL"}
|
|
39
|
+
{"level":"INFO","message":"[4:59:29.611 PM]: Connection[id: 35097e4c-8231-4565-82f3-7c2d2640bdec] - authentication successful using: SNOWFLAKE"}
|
|
40
|
+
{"level":"INFO","message":"[4:59:29.611 PM]: Trying to initialize Easy Logging"}
|
|
41
|
+
{"level":"INFO","message":"[4:59:29.616 PM]: No client config detected."}
|
|
42
|
+
{"level":"INFO","message":"[4:59:29.617 PM]: No config file path found. Client config will not be used."}
|
|
43
|
+
{"level":"INFO","message":"[4:59:29.617 PM]: Easy Logging is disabled as no config has been found"}
|
|
44
|
+
{"level":"INFO","message":"[4:59:29.620 PM]: Connection[id: 35097e4c-8231-4565-82f3-7c2d2640bdec] - connected successfully after 10.1 milliseconds"}
|