backend-plus 2.0.0-rc.15 → 2.0.0-rc.17
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/lib/backend-plus.d.ts +2 -2
- package/lib/backend-plus.js +23 -13
- package/lib/procedures-table.js +3 -0
- package/package.json +4 -4
- package/unlogged/my-ajax.js +26 -20
package/lib/backend-plus.d.ts
CHANGED
|
@@ -76,7 +76,7 @@ export interface ContextForDump extends Context {
|
|
|
76
76
|
forDump?:boolean
|
|
77
77
|
}
|
|
78
78
|
|
|
79
|
-
export type InformProgressFunction=(opts:Error|{data:any}|{start:any}|{message:string}|{message?:string, lengthComputable:boolean, loaded:number, total:number, force?:boolean})=>void
|
|
79
|
+
export type InformProgressFunction=(opts:Error|{data:any}|{start:any}|{message:string}|{idGroup?:string, message?:string, lengthComputable:boolean, loaded:number, total:number, force?:boolean})=>void
|
|
80
80
|
|
|
81
81
|
export interface ProcedureContext extends Context{
|
|
82
82
|
client:Client
|
|
@@ -184,7 +184,7 @@ export type FieldDefinition = EditableDbDefinition & {
|
|
|
184
184
|
serverSide?:boolean /* default:!clientSide if the value is retrived from the database */
|
|
185
185
|
inTable?:boolean /* default:!clientSide && !sql.fields[...].expr. Is a real fisical field in the table */
|
|
186
186
|
/* sizeByte?:number deprecated size in bytes for numbers */
|
|
187
|
-
|
|
187
|
+
allowEmptyText?:boolean /* if a text field accepts '' as a valid value */
|
|
188
188
|
mobileInputType?:string
|
|
189
189
|
extraRow?:number
|
|
190
190
|
inexactNumber?:number /* default:depends on typeName if = means abs(x-v)<espilon
|
package/lib/backend-plus.js
CHANGED
|
@@ -1552,17 +1552,17 @@ AppBackend.prototype.addProcedureServices = function addProcedureServices(forUnl
|
|
|
1552
1552
|
});
|
|
1553
1553
|
}else{
|
|
1554
1554
|
if(progressInfo.lengthComputable){
|
|
1555
|
-
if
|
|
1556
|
-
context.lastMessageSended=
|
|
1555
|
+
if (!context.lastMessageSended) {
|
|
1556
|
+
context.lastMessageSended = {}
|
|
1557
|
+
}
|
|
1558
|
+
if(new Date()-(context.lastMessageSended[progressInfo.idGroup]||0) > 500 || progressInfo.force){
|
|
1559
|
+
context.lastMessageSended[progressInfo.idGroup]=new Date();
|
|
1557
1560
|
res.write(JSON.stringify({progress:progressInfo})+"\n");
|
|
1558
1561
|
if(progressInfo.total){
|
|
1559
1562
|
var rate100=Math.floor(progressInfo.loaded*100/progressInfo.total);
|
|
1560
1563
|
var rate1000=Math.floor(progressInfo.loaded*1000/progressInfo.total);
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
}else{
|
|
1564
|
-
progress2send={message:rate100+'%', ephemeral:true};
|
|
1565
|
-
}
|
|
1564
|
+
var message = rate100<1 && progressInfo.loaded>0 ? '('+(rate1000||'½')+'‰)' : rate100+'%';
|
|
1565
|
+
progress2send={message, ephemeral:true, idGroup:progressInfo.idGroup};
|
|
1566
1566
|
}
|
|
1567
1567
|
}else{
|
|
1568
1568
|
progress2send=null;
|
|
@@ -2978,22 +2978,32 @@ AppBackend.prototype.dumpDbSchemaPartial = async function dumpDbSchemaPartial(pa
|
|
|
2978
2978
|
lines[0][0]=lines[0][0].replace('\ufeff','')
|
|
2979
2979
|
}
|
|
2980
2980
|
rows=lines.slice(1);
|
|
2981
|
+
var filteredFieldDef = lines[0].filter(filterField);
|
|
2981
2982
|
if(tablesWithStrictSequence[tableName]){
|
|
2982
2983
|
var dataString="COPY "+db.quoteIdent(tableName)+" ("+
|
|
2983
|
-
|
|
2984
|
+
filteredFieldDef.map(db.quoteIdent).join(', ')+
|
|
2984
2985
|
') FROM stdin;\n'+
|
|
2985
2986
|
rows.map(function(line){
|
|
2986
|
-
return line.filter(function(_,i){ return filterField(lines[0][i]);}).map(function(value){
|
|
2987
|
-
|
|
2987
|
+
return line.filter(function(_,i){ return filterField(lines[0][i]);}).map(function(value,i){
|
|
2988
|
+
var def = tableDef.field[filteredFieldDef[i]];
|
|
2989
|
+
return value==='' ? (
|
|
2990
|
+
def.allowEmptyText && ('nullable' in def) && !def.nullable ? '' : '\\N'
|
|
2991
|
+
): value.replace(/\\/g,'\\\\').replace(/\t/g,'\\t').replace(/\n/g,'\\n').replace(/\r/g,'\\r');
|
|
2988
2992
|
}).join('\t')+'\n';
|
|
2989
2993
|
}).join('')+'\\.\n';
|
|
2990
2994
|
}else{
|
|
2991
2995
|
var dataString="insert into "+db.quoteIdent(tableName)+" ("+
|
|
2992
|
-
|
|
2996
|
+
filteredFieldDef.map(db.quoteIdent).join(', ')+
|
|
2993
2997
|
') values\n'+
|
|
2994
2998
|
rows.map(function(line){
|
|
2995
|
-
return "("+line.filter(function(_,i){ return filterField(lines[0][i]);}).map(function(value){
|
|
2996
|
-
|
|
2999
|
+
return "("+line.filter(function(_,i){ return filterField(lines[0][i]);}).map(function(value,i){
|
|
3000
|
+
var def = tableDef.field[filteredFieldDef[i]];
|
|
3001
|
+
if(def == null) {
|
|
3002
|
+
throw Error("no se encuentra la columna "+filteredFieldDef[i]+" en "+tableName);
|
|
3003
|
+
}
|
|
3004
|
+
return value==='' ? (
|
|
3005
|
+
def.allowEmptyText && ('nullable' in def) && !def.nullable ? "''" : 'null'
|
|
3006
|
+
) : db.quoteNullable(value);
|
|
2997
3007
|
}).join(', ')+")";
|
|
2998
3008
|
}).join(',\n')+';\n';
|
|
2999
3009
|
}
|
package/lib/procedures-table.js
CHANGED
|
@@ -823,6 +823,9 @@ ProcedureTables = [
|
|
|
823
823
|
if(value != null && parameters.skipUnknownFieldsAtImport){
|
|
824
824
|
value = value.replace(/(\s|\u00A0)+/g,' ').trim()
|
|
825
825
|
}
|
|
826
|
+
if (value == null && field.allowEmptyText && ('nullable' in field) && !field.nullable ) {
|
|
827
|
+
value = ''
|
|
828
|
+
}
|
|
826
829
|
newRow[field.name]=value;
|
|
827
830
|
}
|
|
828
831
|
});
|
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-rc.
|
|
4
|
+
"version": "2.0.0-rc.17",
|
|
5
5
|
"author": "Codenautas <codenautas@googlegroups.com>",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"repository": "codenautas/backend-plus",
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
"numeral": "^2.0.6",
|
|
60
60
|
"pg-promise-strict": "^1.4.0",
|
|
61
61
|
"pikaday": "^1.8.2",
|
|
62
|
-
"pug": "^3.0.
|
|
62
|
+
"pug": "^3.0.3",
|
|
63
63
|
"read-yaml-promise": "^1.0.2",
|
|
64
64
|
"regexplicit": "^0.1.3",
|
|
65
65
|
"require-bro": "^0.3.1",
|
|
@@ -82,7 +82,7 @@
|
|
|
82
82
|
"@types/js-yaml": "^4.0.9",
|
|
83
83
|
"@types/mocha": "^10.0.6",
|
|
84
84
|
"@types/multiparty": "~0.0.36",
|
|
85
|
-
"@types/node": "^20.
|
|
85
|
+
"@types/node": "^20.14.0",
|
|
86
86
|
"@types/nodemailer": "^6.4.15",
|
|
87
87
|
"@types/numeral": "~2.0.5",
|
|
88
88
|
"@types/session-file-store": "^1.2.5",
|
|
@@ -99,7 +99,7 @@
|
|
|
99
99
|
"kill-9": "~0.4.3",
|
|
100
100
|
"mocha": "^10.4.0",
|
|
101
101
|
"nyc": "^15.1.0",
|
|
102
|
-
"puppeteer": "^22.
|
|
102
|
+
"puppeteer": "^22.10.0",
|
|
103
103
|
"sinon": "^18.0.0",
|
|
104
104
|
"supertest": "^7.0.0",
|
|
105
105
|
"types.d.ts": "~0.6.21",
|
package/unlogged/my-ajax.js
CHANGED
|
@@ -193,14 +193,17 @@ myAjax.ajaxPromise = function ajaxPromise(procedureDef,data,opts){
|
|
|
193
193
|
}
|
|
194
194
|
var result=[];
|
|
195
195
|
var progress=procedureDef.progress!==false;
|
|
196
|
+
/** @type {Record<string,{ divBar, progressBar, progresIndicator, divBarLabel }>} */
|
|
197
|
+
var progressStruct = {}
|
|
196
198
|
var divProgress;
|
|
197
|
-
var divBarProgress;
|
|
198
|
-
var progressBar;
|
|
199
|
-
var progressIndicator;
|
|
200
|
-
var divBarProgressLabel;
|
|
199
|
+
// var divBarProgress = {};
|
|
200
|
+
// var progressBar;
|
|
201
|
+
// var progressIndicator;
|
|
202
|
+
// var divBarProgressLabel = {};
|
|
201
203
|
var onClose=function(){}
|
|
202
204
|
var defaultInformProgress = function defaultInformProgress(progressInfo){
|
|
203
205
|
if(progressInfo.message || progressInfo.end || progressInfo.start || progressInfo.loaded){
|
|
206
|
+
// progressInfo.idGroup
|
|
204
207
|
if(!divProgress){
|
|
205
208
|
var idAutoClose='id-auto-close-'+Math.random();
|
|
206
209
|
var checkAutoClose=html.input({type:'checkbox', id:idAutoClose, checked:myAjax.ajaxPromise.autoClose}).create();
|
|
@@ -235,8 +238,12 @@ myAjax.ajaxPromise = function ajaxPromise(procedureDef,data,opts){
|
|
|
235
238
|
}
|
|
236
239
|
}
|
|
237
240
|
}
|
|
238
|
-
if(progressInfo.
|
|
239
|
-
|
|
241
|
+
if (progressStruct[progressInfo.idGroup] == null) {
|
|
242
|
+
progressStruct[progressInfo.idGroup] = {}
|
|
243
|
+
}
|
|
244
|
+
var ps = progressStruct[progressInfo.idGroup];
|
|
245
|
+
if(progressInfo.ephemeral && ps.divBarLabel){
|
|
246
|
+
ps.divBarLabel.textContent = progressInfo.message;
|
|
240
247
|
}else if(progressInfo.message || progressInfo.end){
|
|
241
248
|
var now=bestGlobals.datetime.now();
|
|
242
249
|
var elapsed = now.sub(tickTime);
|
|
@@ -265,23 +272,23 @@ myAjax.ajaxPromise = function ajaxPromise(procedureDef,data,opts){
|
|
|
265
272
|
);
|
|
266
273
|
}
|
|
267
274
|
}
|
|
268
|
-
if(progressInfo.loaded){
|
|
269
|
-
if(!
|
|
270
|
-
|
|
271
|
-
progressIndicator=html.div({class:'indicator'},' ').create();
|
|
272
|
-
progressBar=html.div({class:'progress-bar', style:'width:400px; height:8px;'},[progressIndicator]).create();
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
progressBar
|
|
275
|
+
if(progressInfo.loaded != null){
|
|
276
|
+
if(!ps.divBar){
|
|
277
|
+
ps.divBarLabel = html.div().create();
|
|
278
|
+
ps.progressIndicator=html.div({class:'indicator'},' ').create();
|
|
279
|
+
ps.progressBar=html.div({class:'progress-bar', style:'width:400px; height:8px;'},[ps.progressIndicator]).create();
|
|
280
|
+
ps.divBar = html.div([
|
|
281
|
+
ps.divBarLabel,
|
|
282
|
+
ps.progressBar
|
|
276
283
|
]).create();
|
|
277
|
-
divProgress.parentNode.insertBefore(
|
|
284
|
+
divProgress.parentNode.insertBefore(ps.divBar, divProgress);
|
|
278
285
|
}
|
|
279
286
|
if(progressInfo.lengthComputable){
|
|
280
|
-
progressIndicator.style.width=progressInfo.loaded*100/progressInfo.total+'%';
|
|
281
|
-
progressIndicator.title=Math.round(progressInfo.loaded*100/progressInfo.total)+'%';
|
|
287
|
+
ps.progressIndicator.style.width=progressInfo.loaded*100/progressInfo.total+'%';
|
|
288
|
+
ps.progressIndicator.title=Math.round(progressInfo.loaded*100/progressInfo.total)+'%';
|
|
282
289
|
}else{
|
|
283
|
-
progressIndicator.style.backgroundColor='#D4D';
|
|
284
|
-
progressIndicator.title='N/D %';
|
|
290
|
+
ps.progressIndicator.style.backgroundColor='#D4D';
|
|
291
|
+
ps.progressIndicator.title='N/D %';
|
|
285
292
|
}
|
|
286
293
|
}
|
|
287
294
|
}
|
|
@@ -304,7 +311,6 @@ myAjax.ajaxPromise = function ajaxPromise(procedureDef,data,opts){
|
|
|
304
311
|
}
|
|
305
312
|
var controlLoggedIn = function controlLoggedIn(result, informNotLoggedIn){
|
|
306
313
|
if(informNotLoggedIn || result && result[0]=="<" && result.match(/login/m)){
|
|
307
|
-
console.log('xxxxxxxxxxx',procedureDef.action)
|
|
308
314
|
my.informDetectedStatus('notLogged');
|
|
309
315
|
throw bestGlobals.changing(new Error(my.messages.notLogged),{displayed:true, isNotLoggedError:true});
|
|
310
316
|
}
|