backend-plus 2.0.0-beta.1 → 2.0.0-beta.4

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.
@@ -652,7 +652,7 @@ myOwn.tableGrid = function tableGrid(tableName, mainElement, opts){
652
652
  if (myOwn.config.config['grid-row-retain-moved-or-deleted']) {
653
653
  var depotsToRetain = grid.depots.filter(depot => depot.tick == tick);
654
654
  for (depot of depotsToRetain) {
655
- if (depot.tr.getAttribute('not-here')) depot.tr.removeAttribute('not-here')
655
+ if (depot.tr && depot.tr.getAttribute('not-here')) depot.tr.removeAttribute('not-here')
656
656
  }
657
657
  }
658
658
  while (depot = depotsToDelete.pop()) {
@@ -418,6 +418,7 @@ export class AppBackend{
418
418
  i18n:{
419
419
  messages:Record<LangId,Record<string, string>>
420
420
  }
421
+ shootDownBackend():Promise<void>
421
422
  }
422
423
 
423
424
  }
@@ -616,6 +616,7 @@ AppBackend.prototype.start = function start(opts){
616
616
  console.log('*','express server');
617
617
  be.server.close(/** @param {Error} err */function(err){
618
618
  if(err){
619
+ console.log('*', err)
619
620
  reject(err);
620
621
  }else{
621
622
  resolve();
@@ -989,21 +990,20 @@ AppBackend.prototype.start = function start(opts){
989
990
  done(null,false,{message:be.messages.unlogged.login.userOrPassFail});
990
991
  }
991
992
  }).then(async function(userInfo){
993
+ if (!userInfo) return;
992
994
  if (!be.config.login.skipBitacora) {
993
995
  var context = be.getContext(req);
994
- var sessionInfo = client.query(be.generateInsertSQL(be.config.server.bitacoraSchema, be.config.server.bitacoraTableName,{
996
+ var sessionInfo = await client.query(be.generateInsertSQL(be.config.server.bitacoraSchema, be.config.server.bitacoraTableName,{
995
997
  procedure_name: '@login',
996
- parameters: {
997
- user:username,
998
- machine_id: context.machineId,
999
- navigator: context.navigator,
1000
- init_date: bestGlobals.datetime.now(),
1001
- }
998
+ username,
999
+ machine_id: context.machineId,
1000
+ navigator: context.navigator,
1001
+ init_date: bestGlobals.datetime.now(),
1002
+ parameters: {}
1002
1003
  })).fetchUniqueValue();
1003
1004
  userInfo.bitacoraId = sessionInfo.value;
1004
1005
  }
1005
1006
  done(null, userInfo);
1006
- return userInfo;
1007
1007
  }).then(function(){
1008
1008
  client.done();
1009
1009
  }).catch(function(err){
@@ -1233,6 +1233,7 @@ AppBackend.prototype.checkDatabaseStructure = async function checkDatabaseStruct
1233
1233
  alter table his.bitacora alter column id type bigint;
1234
1234
  grant usage on schema his to ${be.config.db.user};
1235
1235
  grant select, insert, update on his.bitacora to ${be.config.db.user};
1236
+ alter table his.bitacora alter column parameters_definition drop not null;
1236
1237
  `;
1237
1238
  throw new Error(message);
1238
1239
  }
@@ -2596,8 +2597,13 @@ AppBackend.prototype.dumpDbSchemaPartial = async function dumpDbSchemaPartial(pa
2596
2597
  var schema=db.quoteIdent(be.config.db.schema);
2597
2598
  linesCreate.push("set role to "+owner+";");
2598
2599
  linesCreate.push("drop schema if exists "+schema+' cascade;');
2600
+ if (be.config.install.dump["drop-his"]) {
2601
+ linesCreate.push("drop schema if exists his cascade;");
2602
+ }
2599
2603
  linesCreate.push("create schema "+schema+';');
2600
2604
  linesCreate.push("grant usage on schema "+schema+' to '+user+';');
2605
+ linesCreate.push("create schema if not exists his;");
2606
+ linesCreate.push("grant usage on schema his to "+user+';');
2601
2607
  if(be.config.install.dump["admin-can-create-tables"]){
2602
2608
  linesCreate.push("grant create on schema "+schema+' to '+user+';');
2603
2609
  }
@@ -189,6 +189,9 @@ ProcedureTables = [
189
189
  var updateTarget = {}
190
190
  for(var name in parameters.newRow){
191
191
  var defField=mainDefTable.field[name];
192
+ if (!defField) {
193
+ throw new Error("field "+name+" does not exist in "+mainDefTable.name);
194
+ }
192
195
  if(!defField.allow[action] && (!opts || !opts.forImport) && (
193
196
  !defField.isPk ||
194
197
  parameters.primaryKeyValues[defField.isPk-1]!=parameters.newRow[name]
@@ -2,15 +2,16 @@
2
2
 
3
3
  module.exports = function(context){
4
4
  const BITACORA_TABLENAME = context.be.config.server.bitacoraTableName;
5
+ const BITACORA_SCHEMA = context.be.config.server.bitacoraSchema;
5
6
  return context.be.tableDefAdapt({
6
7
  name:'bitacora',
7
8
  title:'Bitacora',
8
9
  tableName: BITACORA_TABLENAME,
10
+ schema: BITACORA_SCHEMA,
9
11
  editable:context.forDump,
10
12
  fields:[
11
13
  {name:'id' , typeName:'bigint' , nullable:false, sequence:{name: 'secuencia_bitacora', firstValue: 1}},
12
14
  {name:'procedure_name' , typeName:'text' , nullable:false },
13
- {name:'parameters_definition' , typeName:'text' , nullable:false },
14
15
  {name:'parameters' , typeName:'text' , nullable:false },
15
16
  {name:'username' , typeName:'text' , nullable:false },
16
17
  {name:'machine_id' , typeName:'text' , nullable:false },
@@ -3,6 +3,7 @@
3
3
  module.exports = function(context){
4
4
  return context.be.tableDefAdapt({
5
5
  name:'locks',
6
+ schema:'his',
6
7
  allow:{
7
8
  insert:true,
8
9
  delete:false,
@@ -4,6 +4,7 @@ module.exports = function(context){
4
4
  var $1_is_num=`$1 ~ '^\\s*(\\d+(\\.\\d*)?|\\.\\d+)\\s*$'`
5
5
  return context.be.tableDefAdapt({
6
6
  name:'summary',
7
+ schema:'his',
7
8
  editable:context.forDump,
8
9
  fields:[
9
10
  {name:'table_name' , typeName:'text' , visible:false},
@@ -5,6 +5,7 @@ module.exports = function(context){
5
5
  return context.be.tableDefAdapt({
6
6
  name:'tokens',
7
7
  elementName:'token',
8
+ schema:'his',
8
9
  editable:admin,
9
10
  fields:[
10
11
  {name:'token' , typeName:'text' , nullable:false },
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "backend-plus",
3
3
  "description": "Backend for the anti Pareto rule",
4
- "version": "2.0.0-beta.1",
4
+ "version": "2.0.0-beta.4",
5
5
  "author": "Codenautas <codenautas@googlegroups.com>",
6
6
  "license": "MIT",
7
7
  "repository": "codenautas/backend-plus",
@@ -54,7 +54,7 @@
54
54
  "mini-tools": "^1.12.1",
55
55
  "moment": "^2.29.4",
56
56
  "multiparty": "^4.2.3",
57
- "nodemailer": "^6.9.3",
57
+ "nodemailer": "^6.9.4",
58
58
  "numeral": "^2.0.6",
59
59
  "pg-promise-strict": "^1.3.3",
60
60
  "pikaday": "^1.8.2",
@@ -81,8 +81,8 @@
81
81
  "@types/js-yaml": "^4.0.5",
82
82
  "@types/mocha": "^10.0.1",
83
83
  "@types/multiparty": "~0.0.33",
84
- "@types/node": "^20.3.3",
85
- "@types/nodemailer": "^6.4.8",
84
+ "@types/node": "^20.4.5",
85
+ "@types/nodemailer": "^6.4.9",
86
86
  "@types/numeral": "~2.0.2",
87
87
  "@types/session-file-store": "^1.2.2",
88
88
  "@types/stack-trace": "~0.0.30",
@@ -98,10 +98,10 @@
98
98
  "kill-9": "~0.4.3",
99
99
  "mocha": "^10.2.0",
100
100
  "nyc": "^15.1.0",
101
- "puppeteer": "^20.7.4",
101
+ "puppeteer": "^20.9.0",
102
102
  "sinon": "^15.2.0",
103
103
  "supertest": "^6.3.3",
104
- "types.d.ts": "~0.6.15",
104
+ "types.d.ts": "~0.6.16",
105
105
  "typescript": "^5.1.6",
106
106
  "why-is-node-running": "^2.2.2"
107
107
  },