Comparing version 1.0.17 to 1.0.18
@@ -1,2 +0,2 @@ | ||
#!/bin/node | ||
#!/usr/bin/env node | ||
//Return information about the currently installed wylib package | ||
@@ -3,0 +3,0 @@ //Copyright WyattERP.org; See license in root of this package |
@@ -44,3 +44,3 @@ //Manage the connection between a User Interface and the backend database | ||
, validateToken = (user, token, pub, listen, payload, cb) => { //Validate user with one-time login token | ||
log.trace("Request to validate:", user) | ||
log.debug("Request to validate:", user, "tok:", token) | ||
adminDB.query('select base.validate_token($1,$2,$3) as valid', [user, token, pub], (err, res)=>{ | ||
@@ -59,15 +59,15 @@ if (err) log.error("Error validating user:", user, token, err) | ||
let pubKey = (!err && res && res.rows && res.rows.length >= 1) ? res.rows[0].conn_pub : null | ||
, valid = false | ||
, valid = false //Assume failure | ||
log.trace(" public key:", pubKey, res ? res.rows : null) | ||
if (pubKey && sign) { | ||
let rawKey = Buffer.from(pubKey, 'hex') | ||
if (pubKey && sign) { //We have the public key from the DB and the signed hash from the client | ||
let rawKey = Buffer.from(pubKey, 'hex') //Hex-to-binary | ||
, rawSig = Buffer.from(sign, 'hex') | ||
, key = PemHeader + Base64.fromByteArray(rawKey) + PemFooter | ||
, verify = Crypto.createVerify('SHA256') | ||
, key = PemHeader + Base64.fromByteArray(rawKey) + PemFooter //Raw-to-PEM | ||
, verify = Crypto.createVerify('SHA256') //Make a verifier | ||
log.trace(" user public:", user, key) | ||
verify.update(message) | ||
valid = verify.verify(Object.assign({key}, VerifyTpt), rawSig) | ||
verify.update(message) //Give it our message | ||
valid = verify.verify(Object.assign({key}, VerifyTpt), rawSig) //And check it | ||
if (valid) Object.assign(payload, {user,listen}) //Tell later db connect our username and db listen options | ||
} | ||
log.trace(" valid:", valid) | ||
log.debug(" valid:", valid) | ||
cb(valid) | ||
@@ -193,3 +193,3 @@ }) | ||
let tuples = 1, result = {query: null, parms: [], error: null} | ||
switch (action) { | ||
try { switch (action) { | ||
case 'tuple': | ||
@@ -212,2 +212,5 @@ this.buildSelect(result, {fields, table, argtypes, params, where}); break; | ||
result.error = this.error('unknown action: ' + action, 'badAction') | ||
}} catch(e) { | ||
result.error = this.error('parsing: ' + e.message) | ||
this.log.error(e.message, e.stack) | ||
} | ||
@@ -356,8 +359,20 @@ if (result.error) { | ||
return Format("%s(%I %s)", logic.not ? 'not ' : '', logic.left, logic.oper) | ||
} else if (logic.oper == 'true') { | ||
} else if (logic.oper == 'true') { //LHS only | ||
return Format("%s%I", logic.not ? 'not ' : '', logic.left) | ||
} else if (logic.oper == 'in') { | ||
if (logic.entry) { | ||
return Format("%s(%I in (%L))", logic.not ? 'not ' : '', logic.left, logic.entry.split(',')) | ||
} else if (logic.right) { | ||
} else if (logic.oper == 'in') { //LHS in array or set | ||
if (logic.entry) { //RHS is explicit | ||
let right = logic.entry | ||
, notter = logic.not ? 'not ' : '' | ||
if (Array.isArray(right)) //Map array sub-elements to strings | ||
right = right.map(el=>(Array.isArray(el) ? el.join('~') : el)) | ||
if (typeof right == 'string') right = right.split(/[ ,]+/) //Comma separated list | ||
if (Array.isArray(logic.left)) { //Matching multiple fields against array sub-elements | ||
let left = logic.left.map(el=>(Format("%I", el))).join("||'~'||") //Map LHS to tilde joined string | ||
return Format("%s(%s in (%L))", notter, left, right) | ||
} | ||
return Format("%s(%I in (%L))", notter, logic.left, right) | ||
} else if (logic.right) { //RHS is a DB field | ||
return Format("%s(%I = any(%I))", logic.not ? 'not ' : '', logic.left, logic.right) | ||
@@ -367,2 +382,3 @@ } else { | ||
} | ||
} else { | ||
@@ -369,0 +385,0 @@ res.parms.push(logic.entry || logic.right || '') |
{ | ||
"name": "wyseman", | ||
"version": "1.0.17", | ||
"version": "1.0.18", | ||
"description": "PostgreSQL Schema Manager with Javascript, Ruby, TCL API", | ||
@@ -34,9 +34,9 @@ "main": "lib/index.js", | ||
"base64-js": "^1.3.1", | ||
"pg": "^7.14.0", | ||
"pg": "^8.0.3", | ||
"pg-format": "^1.0.4", | ||
"ws": "^7.2.0" | ||
"ws": "^7.2.5" | ||
}, | ||
"devDependencies": { | ||
"mocha": "^6.2.2" | ||
"mocha": "^7.1.2" | ||
} | ||
} |
@@ -16,3 +16,3 @@ ## Wyseman: WyattERP Schema Manager | ||
This is how it works. | ||
You author your SQL objects inside TCL containers like this: | ||
You author your SQL objects inside TCL data containers like this: | ||
``` | ||
@@ -25,6 +25,5 @@ table myschema.mytable {dependency1 dependency2 ...} { | ||
``` | ||
This tells wyseman what your object is, how to create it, | ||
and unless it is already obvious, how to drop it. | ||
Most importantly, it tells if there are other objects that | ||
will have to be recreated as well if we want to rebuilt this one. | ||
This tells wyseman what your object is, how to create it, and unless it is | ||
self-evident, how to drop it. Most importantly, it tells if there are other | ||
objects that will have to be recreated as well if we want to rebuilt this one. | ||
@@ -34,4 +33,3 @@ There are two other very similar object decriptions you can make too: | ||
1. A *tabtext* contains language data about the table, columns, and possible | ||
values for your data. | ||
You can define this for any number of different languages. | ||
values for your data. You can define this for any number of different languages. | ||
For example: | ||
@@ -51,15 +49,12 @@ | ||
2. A *tabdef* contains information about how your tables | ||
and views should normally render and otherwise, be handled, | ||
in the user's view. | ||
2. A *tabdef* contains information about how your tables and views should | ||
normally render and otherwise, be handled, in the user's view. | ||
Once you have your schema defined, just tell wyseman to build it | ||
from your files. | ||
Once you have your schema defined, just tell wyseman to build it from your files. | ||
It will store all your objects into a special schema in the database. | ||
And on your command, it will build the target schema you have just | ||
designed. | ||
And on your command, it will build the target schema you have just designed. | ||
Then, as you make changes to your object definitions, wyseman can | ||
modify and upgrade the running database, without disrupting any | ||
data it may contain, to keep it current with your design. | ||
Then, as you make changes to your object definitions, wyseman can modify and | ||
upgrade the running database, without disrupting any data it may contain, to | ||
keep it current with your design. | ||
@@ -72,10 +67,10 @@ Now go create your frontend using [Wylib](http://github.com/gotchoices/wylib) | ||
[Wyselib](http://github.com/gotchoices/wyselib) | ||
that contains a bunch of basic schema components for handling common | ||
things like people, accounts, products, etc. | ||
that contains a bunch of basic schema components for handling common things | ||
like people, accounts, products, etc. | ||
These packages work together to make it relatively painless to make | ||
and more importantly, *maintain* a production database application. | ||
These packages work together to make it relatively painless to make and more | ||
importantly, *maintain* a production database application. | ||
---- | ||
### Background | ||
### Background History | ||
When I first started using SQL relational databases, there was one issue | ||
@@ -82,0 +77,0 @@ I continually struggled with: How is it best to maintain the source |
@@ -7,5 +7,5 @@ //Build test database and check it | ||
const { DatabaseName, DBAdmin } = require('../settings') | ||
const Log = require(require.resolve('wyclif/lib/log.js')) | ||
var log = Log('test-checkdb') | ||
var fs = require('fs') | ||
//var logger = require('util').debuglog('checkdb') | ||
var log = new (require('../logger'))('checkdb') | ||
var dbClient = require("../../lib/dbclient.js") | ||
@@ -32,6 +32,6 @@ const dbConfig = { | ||
it('Check for undocumented tables', function(done) { | ||
let sql = "select sch,tab from wm.table_lang where language = 'en' and help is null and sch = 'wm' order by 1,2" | ||
let sql = "select sch,tab from wm.table_lang where language = 'en' and help isnull and sch = 'wm' order by 1,2" | ||
db.query(sql, null, (err, res) => { | ||
if (err) done(err) | ||
log.debug("Result:", res.rows) | ||
log.debug("Tables:", res.rows) | ||
assert.equal(res.rows.length, 0) | ||
@@ -43,6 +43,7 @@ done() | ||
it('Check for undocumented columns', function(done) { | ||
let sql = "select sch,tab,col from wm.column_lang where language = 'en' and help is null and sch = 'wm' order by 1,2" | ||
let sql = "select sch,tab,col from wm.column_lang where language = 'en' and help isnull and sch = 'wm' order by 1,2" | ||
log.debug("SQL:", sql) | ||
db.query(sql, null, (err, res) => { | ||
if (err) done(err) | ||
log.debug("Result:", JSON.stringify(res.rows)) | ||
log.debug("Columns:", res.rows.length, res.rows) | ||
assert.equal(res.rows.length, 0) | ||
@@ -49,0 +50,0 @@ if (res.rows.length == 0) done() |
@@ -7,4 +7,5 @@ //Check table styles in data dictionary | ||
const { DatabaseName, DBAdmin } = require('../settings') | ||
const Log = require(require.resolve('wyclif/lib/log.js')) | ||
var log = Log('test-metadata') | ||
var fs = require('fs') | ||
var log = new (require('../logger'))('metadata') | ||
var dbClient = require("../../lib/dbclient.js") | ||
@@ -11,0 +12,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
668360
70
671
227
6
+ Addedpg@8.13.1(transitive)
+ Addedpg-cloudflare@1.1.1(transitive)
+ Addedpg-connection-string@2.7.0(transitive)
+ Addedpg-pool@3.7.0(transitive)
+ Addedpg-protocol@1.7.0(transitive)
- Removedbuffer-writer@2.0.0(transitive)
- Removedpacket-reader@1.0.0(transitive)
- Removedpg@7.18.2(transitive)
- Removedpg-connection-string@0.1.3(transitive)
- Removedpg-packet-stream@1.1.0(transitive)
- Removedpg-pool@2.0.10(transitive)
- Removedsemver@4.3.2(transitive)
Updatedpg@^8.0.3
Updatedws@^7.2.5