backend-plus 1.14.6 → 1.14.10

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.
@@ -286,15 +286,6 @@ myOwn.showPage = function showPage(pageDef){
286
286
  }
287
287
  };
288
288
 
289
- myOwn.menuName = 'menu';
290
- myOwn.menuSeparator = '#';
291
- Object.defineProperty(myOwn, 'menup', {
292
- get:function(){
293
- var menuName = my.offline.mode?'ext':this.menuName;
294
- return menuName+this.menuSeparator;
295
- }
296
- });
297
-
298
289
  myOwn.getHRef = function getHRef(menu){
299
290
  var href;
300
291
  if(!menu.w && menu.menuType){
@@ -363,33 +354,6 @@ myOwn.createForkeableButton = function createForkeableButton(menu, opts){
363
354
  return button;
364
355
  };
365
356
 
366
- function encodeMinimalURIComponent(text){
367
- return (text+'')
368
- .replace(/\=/g, '%3D')
369
- .replace(/\?/g, '%3F')
370
- .replace(/\#/g, '%23')
371
- .replace(/&/g, '%26')
372
- .replace(/%/g, '%25');
373
- }
374
-
375
- myOwn.paramsToUriPart = function paramsToUriPart(params, inMenu){
376
- var paramStr=likeAr(params).map(function(value, name){
377
- var paramDef=myOwn.UriSearchToObjectParams[name] || { encode:function(x){return x}, varName:name };
378
- if((paramDef.showInMenu || !inMenu) && !paramDef.hide || (params.showParams && params.showParams.includes(name))){
379
- if(value!=null){
380
- value=paramDef.encode(value, params);
381
- return (paramDef.varName||name)+'='+encodeMinimalURIComponent(value);
382
- }
383
- }
384
- }).filter(function(expr){return expr;}).join('&');
385
- return paramStr;
386
- }
387
-
388
- myOwn.replaceAddrParams = function replaceAddrParams(params){
389
- var my=this;
390
- history.replaceState(null, null, my.menup+my.paramsToUriPart(params));
391
- }
392
-
393
357
  myOwn.light = function light(name, onclick, opts){
394
358
  var skin=((this.config||{}).config||{}).skin;
395
359
  var skinUrl=(skin?skin+'/':'');
@@ -2717,6 +2717,9 @@ myOwn.getReference = function getReference(referenceName, opts){
2717
2717
  getLabel: function getLabel(row){
2718
2718
  return this.getLabels(row).join(', ');
2719
2719
  },
2720
+ getImage: function getImage(row){
2721
+ return row.image?'img/'+row.image:'';
2722
+ },
2720
2723
  fixedFields:[]
2721
2724
  },opts||{});
2722
2725
  var reference={};
@@ -2742,6 +2745,7 @@ myOwn.getReference = function getReference(referenceName, opts){
2742
2745
  reference.getValue = opts.getValue;
2743
2746
  reference.getLabels = opts.getLabels;
2744
2747
  reference.getLabel = opts.getLabel;
2748
+ reference.getImage = opts.getImage;
2745
2749
  return rows;
2746
2750
  });
2747
2751
  reference=my.references[referenceName]={
@@ -2854,7 +2858,8 @@ myOwn.ExpanderReferences={
2854
2858
  var menu=rows.map(function(row){
2855
2859
  return {
2856
2860
  value:reference.getValue(row),
2857
- labels:reference.getLabels(row,true)
2861
+ labels:reference.getLabels(row,true),
2862
+ img:reference.getImage(row)
2858
2863
  };
2859
2864
  });
2860
2865
  if(typeInfo.nullable){
@@ -804,16 +804,6 @@ myOwn.captureKeys = function captureKeys() {
804
804
  });
805
805
  };
806
806
 
807
- myOwn.getRect = function getRect(element){
808
- var rect = {top:0, left:0, width:element.offsetWidth, height:element.offsetHeight};
809
- while( element != null ) {
810
- rect.top += element.offsetTop;
811
- rect.left += element.offsetLeft;
812
- element = element.offsetParent;
813
- }
814
- return rect;
815
- }
816
-
817
807
  // myOwn.quitarLupa = function quitarLupa(){
818
808
  // if(document.buttonLupa){
819
809
  // document.body.removeChild(document.buttonLupa);
@@ -581,7 +581,7 @@ AppBackend.prototype.start = function start(opts){
581
581
  console.log("==============================================");
582
582
  console.log("ERROR controling not index.* in privates paths");
583
583
  console.log(err);
584
- process.exit();
584
+ process.exit(1);
585
585
  });
586
586
  });
587
587
  /** @type {Express.Application} */
@@ -1092,7 +1092,7 @@ AppBackend.prototype.start = function start(opts){
1092
1092
  }
1093
1093
  if(err.dumping){
1094
1094
  console.log('error dumping db');
1095
- process.exit(0);
1095
+ process.exit(1);
1096
1096
  }
1097
1097
  var mailDeAvisoDeFalla = be.sendMail({
1098
1098
  to: be.config.mailer?.supervise?.to,
@@ -1114,7 +1114,7 @@ AppBackend.prototype.start = function start(opts){
1114
1114
  },function(){
1115
1115
  console.log('no pudo avisarse por mail')
1116
1116
  }).finally(function(){
1117
- process.exit(-1);
1117
+ process.exit(1);
1118
1118
  });
1119
1119
  });
1120
1120
  };
@@ -2699,7 +2699,8 @@ AppBackend.prototype.dumpDbSchemaPartial = async function dumpDbSchemaPartial(pa
2699
2699
  }
2700
2700
  var enancePart= 'do $SQL_ENANCE$\n begin\n' + enanceLines.join('\n')+'\n' + 'end\n$SQL_ENANCE$;';
2701
2701
  var someNotFound=false;
2702
- return Promise.all(Object.keys(partialTableStructures).map(function(tableName,i){
2702
+ return Promise.all(likeAr(partialTableStructures).map(function(tableDef, tableName, _, i){
2703
+ if(tableDef?.sql?.isTable === false) return;
2703
2704
  // TODO: buscar
2704
2705
  var buscarEn=[Path.join('local-install',tableName+'.tab')].concat(
2705
2706
  be.appStack.map(function(stackNode){
@@ -2798,7 +2799,7 @@ AppBackend.prototype.dumpDbSchemaPartial = async function dumpDbSchemaPartial(pa
2798
2799
  throw err;
2799
2800
  }
2800
2801
  });
2801
- })).then(function(){
2802
+ }).array()).then(function(){
2802
2803
  if(someNotFound){
2803
2804
  console.log('silence "skipping content" messages in "local-config.yaml".install.dump.skip-content=true');
2804
2805
  }
@@ -264,7 +264,7 @@ function tableDefAdapt(tableDef, context){
264
264
  fkDef.displayFields = fkDef.displayAllFields?
265
265
  (fkTableDef.fields.filter(fd=>fd.visible && !fd.clientSide && !resultTableDef.field[fd.name] && !fd.inJoin && !fkTableDef.sql.fields[fd.name]).map(fd=>fd.name)): //EVALUAR SI ESTÁ BIEN COMENTARLO
266
266
  fkDef.displayFields || fkTableDef.nameFields;
267
- resultTableDef.sql.from += '\n left join ' + fkTableDef.sql.fromWoAs + ' as ' + fkDef.alias + ' on ' +
267
+ resultTableDef.sql.from += '\n left join ' + fkTableDef.sql.fromWoAs + ' as ' + be.db.quoteIdent(fkDef.alias) + ' on ' +
268
268
  fkDef.fields.map(function(pair){
269
269
  lastSourceField = pair.source;
270
270
  return be.db.quoteIdent(resultTableDef.alias)+'.'+be.db.quoteIdent(pair.source)
@@ -345,11 +345,11 @@ tableDefAdapt.forInsertOnly = function forInsertOnly(tableDef){
345
345
  tableDef.fields.sort(bestGlobals.compareForOrder([{column:'orderForInsertOnly'}]))
346
346
  tableDef.sql.select = tableDef.fields.map(function(fieldDef){
347
347
  var typer=TypeStore.typerFrom(fieldDef);
348
- return (fieldDef.inTable===false || fieldDef.inJoin) && tableDef.sql.fields[fieldDef.name] ?"null::"+typer.typeDbPg+" as "+JSON.stringify(fieldDef.name):(
348
+ return (fieldDef.inTable===false || fieldDef.inJoin) && tableDef.sql.fields[fieldDef.name] ?"null::"+typer.typeDbPg+" as "+be.db.quoteIdent(fieldDef.name):(
349
349
  fieldDef.referencedName?(
350
- JSON.stringify(fieldDef.referencedAlias)+"."+JSON.stringify(fieldDef.referencedName)+" as "+JSON.stringify(fieldDef.name)
350
+ be.db.quoteIdent(fieldDef.referencedAlias)+"."+be.db.quoteIdent(fieldDef.referencedName)+" as "+be.db.quoteIdent(fieldDef.name)
351
351
  ):(
352
- JSON.stringify(tableDef.alias)+"."+JSON.stringify(fieldDef.name)
352
+ be.db.quoteIdent(tableDef.alias)+"."+be.db.quoteIdent(fieldDef.name)
353
353
  )
354
354
  );
355
355
  });
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "backend-plus",
3
3
  "description": "Backend for typed controls",
4
- "version": "1.14.6",
4
+ "version": "1.14.10",
5
5
  "author": "Codenautas <codenautas@googlegroups.com>",
6
6
  "license": "MIT",
7
7
  "repository": "codenautas/backend-plus",
@@ -30,7 +30,7 @@
30
30
  "dependencies": {
31
31
  "ajax-best-promise": "^0.3.7",
32
32
  "backend-skins": "^0.1.15",
33
- "best-globals": "^1.0.1",
33
+ "best-globals": "^1.0.2",
34
34
  "big.js": "^6.1.1",
35
35
  "body-parser": "^1.19.1",
36
36
  "cast-error": "^0.1.0",
@@ -70,27 +70,27 @@
70
70
  "stylus": "^0.56.0",
71
71
  "type-store": "^0.2.41",
72
72
  "typed-controls": "^0.10.0",
73
- "xlsx": "^0.17.4",
73
+ "xlsx": "^0.17.5",
74
74
  "xlsx-style": "^0.8.13"
75
75
  },
76
76
  "devDependencies": {
77
77
  "@types/big.js": "^6.1.2",
78
78
  "@types/expect.js": "~0.3.29",
79
79
  "@types/express": "^4.17.13",
80
- "@types/express-useragent": "^1.0.1",
80
+ "@types/express-useragent": "^1.0.2",
81
81
  "@types/fs-extra": "^9.0.13",
82
82
  "@types/js-yaml": "^4.0.5",
83
83
  "@types/mocha": "^9.0.0",
84
84
  "@types/nodemailer": "^6.4.4",
85
85
  "@types/multiparty": "~0.0.33",
86
- "@types/node": "^17.0.6",
86
+ "@types/node": "^17.0.8",
87
87
  "@types/numeral": "~2.0.2",
88
88
  "@types/session-file-store": "^1.2.2",
89
89
  "@types/stack-trace": "~0.0.29",
90
90
  "@types/websql": "~0.0.27",
91
91
  "esprima": "^4.0.1",
92
92
  "expect.js": "~0.3.1",
93
- "karma": "6.3.9",
93
+ "karma": "6.3.11",
94
94
  "karma-chrome-launcher": "^3.1.0",
95
95
  "karma-expect": "^1.1.3",
96
96
  "karma-firefox-launcher": "^2.1.2",
@@ -101,7 +101,7 @@
101
101
  "nyc": "^15.1.0",
102
102
  "puppeteer": "^13.0.1",
103
103
  "sinon": "^12.0.1",
104
- "supertest": "^6.1.6",
104
+ "supertest": "^6.2.1",
105
105
  "types.d.ts": "~0.6.6",
106
106
  "typescript": "^4.5.4",
107
107
  "why-is-node-running": "^2.2.0"
@@ -609,6 +609,52 @@ myAjax.UriSearchToObject = function UriSearchToObject(locationSearch){
609
609
  return addrParams;
610
610
  }
611
611
 
612
+ myAjax.replaceAddrParams = function replaceAddrParams(params){
613
+ var my=this;
614
+ history.replaceState(null, null, my.menup+my.paramsToUriPart(params));
615
+ }
616
+
617
+ function encodeMinimalURIComponent(text){
618
+ return (text+'')
619
+ .replace(/\=/g, '%3D')
620
+ .replace(/\?/g, '%3F')
621
+ .replace(/\#/g, '%23')
622
+ .replace(/&/g, '%26')
623
+ .replace(/%/g, '%25');
624
+ }
625
+
626
+ myAjax.paramsToUriPart = function paramsToUriPart(params, inMenu){
627
+ var paramStr=likeAr(params).map(function(value, name){
628
+ var paramDef=myOwn.UriSearchToObjectParams[name] || { encode:function(x){return x}, varName:name };
629
+ if((paramDef.showInMenu || !inMenu) && !paramDef.hide || (params.showParams && params.showParams.includes(name))){
630
+ if(value!=null){
631
+ value=paramDef.encode(value, params);
632
+ return (paramDef.varName||name)+'='+encodeMinimalURIComponent(value);
633
+ }
634
+ }
635
+ }).filter(function(expr){return expr;}).join('&');
636
+ return paramStr;
637
+ }
638
+
639
+ myAjax.getRect = function getRect(element){
640
+ var rect = {top:0, left:0, width:element.offsetWidth, height:element.offsetHeight};
641
+ while( element != null ) {
642
+ rect.top += element.offsetTop;
643
+ rect.left += element.offsetLeft;
644
+ element = element.offsetParent;
645
+ }
646
+ return rect;
647
+ }
648
+
649
+ myAjax.menuName = 'menu';
650
+ myAjax.menuSeparator = '#';
651
+ Object.defineProperty(myOwn, 'menup', {
652
+ get:function(){
653
+ var menuName = my.offline.mode?'ext':this.menuName;
654
+ return menuName+this.menuSeparator;
655
+ }
656
+ });
657
+
612
658
  return myAjax;
613
659
 
614
660
  });