backend-plus 1.17.6 → 1.17.7
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/for-client/my-localdb.d.ts +6 -6
- package/for-client/my-localdb.js +1 -1
- package/for-client/my-tables.js +25 -23
- package/for-client/my-websqldb.d.ts +2 -2
- package/for-client/my-websqldb.js +1 -1
- package/lib/backend-plus.d.ts +4 -2
- package/lib/backend-plus.js +22 -10
- package/package.json +5 -5
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { ForeignKey, FieldDefinition } from "backend-plus";
|
|
2
|
-
export
|
|
3
|
-
export
|
|
2
|
+
export type Key = string[];
|
|
3
|
+
export type Stores = {
|
|
4
4
|
[key: string]: IDBObjectStore;
|
|
5
5
|
};
|
|
6
|
-
export
|
|
6
|
+
export type StoreDefs = {
|
|
7
7
|
[key: string]: Key | string;
|
|
8
8
|
};
|
|
9
|
-
export
|
|
9
|
+
export type Record = {
|
|
10
10
|
[key: string]: any;
|
|
11
11
|
};
|
|
12
12
|
export interface TableDefinition {
|
|
@@ -16,12 +16,12 @@ export interface TableDefinition {
|
|
|
16
16
|
softForeignKeys?: ForeignKey[];
|
|
17
17
|
fields: FieldDefinition[];
|
|
18
18
|
}
|
|
19
|
-
|
|
19
|
+
type RegisterResult = {
|
|
20
20
|
new?: true;
|
|
21
21
|
dataErased?: true;
|
|
22
22
|
changed: boolean;
|
|
23
23
|
};
|
|
24
|
-
|
|
24
|
+
type DetectFeatures = {
|
|
25
25
|
needToUnwrapArrayKeys: boolean;
|
|
26
26
|
};
|
|
27
27
|
export declare var detectedFeatures: DetectFeatures;
|
package/for-client/my-localdb.js
CHANGED
|
@@ -13,7 +13,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
13
13
|
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
14
14
|
function step(op) {
|
|
15
15
|
if (f) throw new TypeError("Generator is already executing.");
|
|
16
|
-
while (_) try {
|
|
16
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
17
17
|
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
18
18
|
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
19
19
|
switch (op[0]) {
|
package/for-client/my-tables.js
CHANGED
|
@@ -75,6 +75,7 @@ myOwn.i18n.messages.en=changing(myOwn.i18n.messages.en, {
|
|
|
75
75
|
lessDetails: "hide details",
|
|
76
76
|
lessEqualThan:'less equal than',
|
|
77
77
|
loading: "loading",
|
|
78
|
+
mandatoryFieldOmited:'mandatory fields omited: ',
|
|
78
79
|
newUnsavedRow: "new unsaved row",
|
|
79
80
|
notEmpty:'not empty',
|
|
80
81
|
notSimilarTo:'not similar to',
|
|
@@ -144,6 +145,7 @@ myOwn.i18n.messages.es=changing(myOwn.i18n.messages.es, {
|
|
|
144
145
|
lessDetails: "dejar de mostrar los detalles asocialdos al registro",
|
|
145
146
|
lessEqualThan:'menor igual que',
|
|
146
147
|
loading: "cargando",
|
|
148
|
+
mandatoryFieldOmited:'faltan campos obligatorios: ',
|
|
147
149
|
newUnsavedRow: "el nuevo registro (aun no grabado)",
|
|
148
150
|
notEmpty:'no vacío',
|
|
149
151
|
notSimilarTo:'no contiene',
|
|
@@ -613,7 +615,7 @@ myOwn.tableGrid = function tableGrid(tableName, mainElement, opts){
|
|
|
613
615
|
} else if (!depot) {
|
|
614
616
|
var depot = grid.createDepotFromRow(row);
|
|
615
617
|
grid.depots.push(depot);
|
|
616
|
-
grid.
|
|
618
|
+
grid.sortDepotsToDisplay(grid.depots);
|
|
617
619
|
grid.createRowElements(grid.depots.findIndex((myDepot)=>myDepot===depot), depot);
|
|
618
620
|
grid.updateRowData(depot);
|
|
619
621
|
depot.tick = tick
|
|
@@ -1030,13 +1032,15 @@ myOwn.DataColumnGrid.prototype.td = function td(depot, iColumn, tr, saveRow){
|
|
|
1030
1032
|
}
|
|
1031
1033
|
var promiseChain = Promise.resolve();
|
|
1032
1034
|
if (fieldDef.references) {
|
|
1033
|
-
promiseChain.then(
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1035
|
+
promiseChain = promiseChain.then(
|
|
1036
|
+
grid.setInheritedFields(depot, function(fkDef){
|
|
1037
|
+
return fkDef.references == fieldDef.references &&
|
|
1038
|
+
fkDef.fields.find(function(field){
|
|
1039
|
+
return field.source == fieldDef.name
|
|
1040
|
+
}) &&
|
|
1041
|
+
fkDef.displayFields.length >= 0
|
|
1042
|
+
}
|
|
1043
|
+
));
|
|
1040
1044
|
}
|
|
1041
1045
|
promiseChain.then(function(){
|
|
1042
1046
|
grid.updateRowData(depot,true);
|
|
@@ -2063,7 +2067,7 @@ myOwn.TableGrid.prototype.prepareGrid = function prepareGrid(){
|
|
|
2063
2067
|
grid.setInheritedFields = function(depot, filterFun){
|
|
2064
2068
|
var promiseArray = [];
|
|
2065
2069
|
grid.def.foreignKeys.concat(grid.def.softForeignKeys).filter(filterFun||(x=>x))
|
|
2066
|
-
.filter(x=>x.
|
|
2070
|
+
.filter(x=>(x.inheritFieldsMode ?? my.config.config['inherit-fields-mode']) != 'no-inherit' ).forEach(function(fkDef){
|
|
2067
2071
|
var fixedFields = fkDef.fields.map(function(field){
|
|
2068
2072
|
return {fieldName: field.target, value: depot.row[field.source]};
|
|
2069
2073
|
})
|
|
@@ -2079,18 +2083,12 @@ myOwn.TableGrid.prototype.prepareGrid = function prepareGrid(){
|
|
|
2079
2083
|
promiseArray.push(
|
|
2080
2084
|
myConnector.getData().then(function(data){
|
|
2081
2085
|
var referencedRow = data[0];
|
|
2082
|
-
|
|
2083
|
-
var
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
depot.rowPendingForUpdate[fieldName] = lookupValue;
|
|
2089
|
-
}
|
|
2090
|
-
depot.row[fieldName]=lookupValue;
|
|
2091
|
-
if(depot.rowControls[fieldName]){
|
|
2092
|
-
depot.rowControls[fieldName].setTypedValue(lookupValue);
|
|
2093
|
-
}
|
|
2086
|
+
fkDef.displayFields.forEach(function(displayFieldName){
|
|
2087
|
+
var lookupValue=referencedRow?referencedRow[displayFieldName]:null;
|
|
2088
|
+
var fieldName = fkDef.alias + '__' + displayFieldName;
|
|
2089
|
+
depot.row[fieldName]=lookupValue;
|
|
2090
|
+
if(depot.rowControls[fieldName]){
|
|
2091
|
+
depot.rowControls[fieldName].setTypedValue(lookupValue);
|
|
2094
2092
|
}
|
|
2095
2093
|
})
|
|
2096
2094
|
})
|
|
@@ -2281,6 +2279,10 @@ myOwn.TableGrid.prototype.displayGrid = function displayGrid(){
|
|
|
2281
2279
|
}
|
|
2282
2280
|
//var cual=grid.def.fields.filter(mandatoryOmitted)
|
|
2283
2281
|
if(grid.def.fields.some(mandatoryOmitted)){
|
|
2282
|
+
var where = depot.actionButton.insert ?? depot.tr ?? document.getElementById('main-logo') ?? document.body;
|
|
2283
|
+
if(where){
|
|
2284
|
+
where.title = myOwn.messages.mandatoryFieldOmited + grid.def.fields.filter(mandatoryOmitted).map(f=>f.name).join(', ');
|
|
2285
|
+
}
|
|
2284
2286
|
return Promise.resolve(); // no grabo todavía
|
|
2285
2287
|
};
|
|
2286
2288
|
}
|
|
@@ -2571,7 +2573,7 @@ myOwn.TableGrid.prototype.displayGrid = function displayGrid(){
|
|
|
2571
2573
|
}else{
|
|
2572
2574
|
depotsToDisplay = grid.depots;
|
|
2573
2575
|
}
|
|
2574
|
-
grid.
|
|
2576
|
+
grid.sortDepotsToDisplay = function sortDepotsToDisplay(depotsToDisplay){
|
|
2575
2577
|
if(grid.view.sortColumns.length>0){
|
|
2576
2578
|
return depotsToDisplay.sort(function(depot1, depot2){
|
|
2577
2579
|
grid.view.sortColumns.forEach(function(orderColumn){
|
|
@@ -2584,7 +2586,7 @@ myOwn.TableGrid.prototype.displayGrid = function displayGrid(){
|
|
|
2584
2586
|
});
|
|
2585
2587
|
}
|
|
2586
2588
|
}
|
|
2587
|
-
grid.
|
|
2589
|
+
grid.sortDepotsToDisplay(depotsToDisplay);
|
|
2588
2590
|
grid.displayRows = function displayRows(fromRowNumber, toRowNumber, adding){
|
|
2589
2591
|
var grid = this;
|
|
2590
2592
|
if(!adding){
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="websql" />
|
|
2
2
|
import { TableDefinition } from "backend-plus";
|
|
3
|
-
export
|
|
4
|
-
|
|
3
|
+
export type Key = string[];
|
|
4
|
+
type DetectFeatures = {
|
|
5
5
|
needToCopyResults: boolean;
|
|
6
6
|
};
|
|
7
7
|
export declare var detectedFeatures: DetectFeatures;
|
|
@@ -13,7 +13,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
13
13
|
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
14
14
|
function step(op) {
|
|
15
15
|
if (f) throw new TypeError("Generator is already executing.");
|
|
16
|
-
while (_) try {
|
|
16
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
17
17
|
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
18
18
|
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
19
19
|
switch (op[0]) {
|
package/lib/backend-plus.d.ts
CHANGED
|
@@ -318,7 +318,8 @@ export type TableItemDef=string|{name:string, path?:string, tableGenerator?:(con
|
|
|
318
318
|
export interface TableDefinitions {
|
|
319
319
|
[k: string]: TableDefinitionFunction
|
|
320
320
|
}
|
|
321
|
-
export
|
|
321
|
+
export interface ClientSetup {
|
|
322
|
+
setup:Record<string, any>
|
|
322
323
|
procedures:ProcedureDef[]
|
|
323
324
|
}
|
|
324
325
|
export type StartOptions={
|
|
@@ -381,13 +382,14 @@ export class AppBackend{
|
|
|
381
382
|
getMenu(context?:Context):MenuDefinition
|
|
382
383
|
inDbClient<T>(req:Request|null, doThisWithDbClient:(client:Client)=>Promise<T>):Promise<T>
|
|
383
384
|
inTransaction<T>(req:Request|null, doThisWithDbTransaction:(client:Client)=>Promise<T>):Promise<T>
|
|
385
|
+
inTransactionProcedureContext<T>(req:Request|null, coreFunction:(context:ProcedureContext)=>Promise<T>):Promise<T>
|
|
384
386
|
procedureDefCompleter(procedureDef:ProcedureDef):ProcedureDef
|
|
385
387
|
tableDefAdapt(tableDef:TableDefinition, context:Context):TableDefinition
|
|
386
388
|
pushApp(dirname:string):void
|
|
387
389
|
dumpDbTableFields(tableDefinition:TableDefinition):string[]
|
|
388
390
|
dumpDbSchemaPartial(partialTableStructures:TableDefinitions, opts?:DumpOptions):Promise<{mainSql:string; enancePart:string}>
|
|
389
391
|
getContextForDump(): ContextForDump
|
|
390
|
-
getClientSetupForSendToFrontEnd(req:Request):ClientSetup
|
|
392
|
+
getClientSetupForSendToFrontEnd(req:Request):Promise<ClientSetup>
|
|
391
393
|
configList(): (object|string)[]
|
|
392
394
|
configStaticConfig():void
|
|
393
395
|
setStaticConfig(defConfigYamlString:string):void
|
package/lib/backend-plus.js
CHANGED
|
@@ -165,6 +165,7 @@ AppBackend.prototype.configStaticConfig = function configStaticConfig(){
|
|
|
165
165
|
skin: ""
|
|
166
166
|
lang: en
|
|
167
167
|
version: 1.0
|
|
168
|
+
inherit-fields-mode: display-fk
|
|
168
169
|
install:
|
|
169
170
|
dump:
|
|
170
171
|
db:
|
|
@@ -1213,6 +1214,21 @@ AppBackend.prototype.isThisProcedureAllowed = async function(){
|
|
|
1213
1214
|
return true;
|
|
1214
1215
|
}
|
|
1215
1216
|
|
|
1217
|
+
AppBackend.prototype.inTransactionProcedureContext = function inTransactionProcedureContext(req, coreFunction, context){
|
|
1218
|
+
var be = this;
|
|
1219
|
+
context = context ?? be.getContext(req);
|
|
1220
|
+
if(be.config.nodb){
|
|
1221
|
+
return coreFunction(context);
|
|
1222
|
+
}
|
|
1223
|
+
if (!context.informProgress) {
|
|
1224
|
+
context.informProgress = function informProgress(){}
|
|
1225
|
+
}
|
|
1226
|
+
return be.inTransaction(req, function(client){
|
|
1227
|
+
context.client=client;
|
|
1228
|
+
return coreFunction(context);
|
|
1229
|
+
});
|
|
1230
|
+
}
|
|
1231
|
+
|
|
1216
1232
|
/** @param {boolean} forUnlogged */
|
|
1217
1233
|
AppBackend.prototype.addProcedureServices = function addProcedureServices(forUnlogged){
|
|
1218
1234
|
var be = this;
|
|
@@ -1231,12 +1247,12 @@ AppBackend.prototype.addProcedureServices = function addProcedureServices(forUnl
|
|
|
1231
1247
|
be.procedure = be.procedure||{};
|
|
1232
1248
|
be.procedures = defs;
|
|
1233
1249
|
be.clientSetup.procedure = be.procedure;
|
|
1234
|
-
app.get('/client-setup',function(req, res, next){
|
|
1250
|
+
app.get('/client-setup',async function(req, res, next){
|
|
1235
1251
|
if(forUnlogged && req.user){
|
|
1236
1252
|
// este pedido es para unlogged y está logueado, va al próximo
|
|
1237
1253
|
next();
|
|
1238
1254
|
}else{
|
|
1239
|
-
var clientSetup = be.getClientSetupForSendToFrontEnd(req);
|
|
1255
|
+
var clientSetup = await be.getClientSetupForSendToFrontEnd(req);
|
|
1240
1256
|
MiniTools.serveJson(clientSetup)(req, res, next);
|
|
1241
1257
|
}
|
|
1242
1258
|
});
|
|
@@ -1420,7 +1436,7 @@ AppBackend.prototype.addProcedureServices = function addProcedureServices(forUnl
|
|
|
1420
1436
|
}
|
|
1421
1437
|
}
|
|
1422
1438
|
var context=be.getContext(req);
|
|
1423
|
-
if(
|
|
1439
|
+
if(procedureDef.progress!==false){
|
|
1424
1440
|
context.informProgress=function informProgress(progressInfo){
|
|
1425
1441
|
var progress2send={};
|
|
1426
1442
|
if(progressInfo instanceof Error){
|
|
@@ -1507,13 +1523,9 @@ AppBackend.prototype.addProcedureServices = function addProcedureServices(forUnl
|
|
|
1507
1523
|
res.write(JSON.stringify({progress:{keepAlive:true, ts:new Date().getTime()}})+"\n")
|
|
1508
1524
|
},5000)
|
|
1509
1525
|
}
|
|
1510
|
-
|
|
1511
|
-
return procedureDef.coreFunction(context, params, files);
|
|
1512
|
-
}
|
|
1513
|
-
return be.inTransaction(req, function(client){
|
|
1514
|
-
context.client=client;
|
|
1526
|
+
return be.inTransactionProcedureContext(req, function(context){
|
|
1515
1527
|
return procedureDef.coreFunction(context, params, files);
|
|
1516
|
-
});
|
|
1528
|
+
}, context);
|
|
1517
1529
|
}).then(function(result){
|
|
1518
1530
|
if (procedureDef.forExport) {
|
|
1519
1531
|
return be.exportacionesGenerico(result, procedureDef, context, params, files);
|
|
@@ -2401,7 +2413,7 @@ AppBackend.prototype.procedureDefCompleter = function procedureDefCompleter(proc
|
|
|
2401
2413
|
procedureDef.method=procedureDef.method||this.defaultMethod;
|
|
2402
2414
|
procedureDef.encoding=procedureDef.encoding||'JSON4all';
|
|
2403
2415
|
procedureDef.resultOk=procedureDef.resultOk ?? (procedureDef.forExport ? 'showDownloadUrl' : 'showText');
|
|
2404
|
-
procedureDef.progress = procedureDef.progress ??
|
|
2416
|
+
procedureDef.progress = procedureDef.progress ?? (procedureDef.forExport && true);
|
|
2405
2417
|
procedureDef.uniqueUse = procedureDef.uniqueUse ?? !!procedureDef.forExport;
|
|
2406
2418
|
procedureDef.resultErr=procedureDef.resultErr||'showError';
|
|
2407
2419
|
procedureDef.resultClass=procedureDef.resultClass||'result-div';
|
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.17.
|
|
4
|
+
"version": "1.17.7",
|
|
5
5
|
"author": "Codenautas <codenautas@googlegroups.com>",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"repository": "codenautas/backend-plus",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"backend-skins": "^0.1.15",
|
|
34
34
|
"best-globals": "^1.1.0",
|
|
35
35
|
"big.js": "^6.2.1",
|
|
36
|
-
"body-parser": "^1.20.
|
|
36
|
+
"body-parser": "^1.20.2",
|
|
37
37
|
"cast-error": "^0.1.0",
|
|
38
38
|
"castellano": "^0.1.3",
|
|
39
39
|
"connect-pg-simple": "^8.0.0",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"js-yaml": "^4.1.0",
|
|
49
49
|
"json4all": "^1.2.1",
|
|
50
50
|
"lazy-some": "^0.1.0",
|
|
51
|
-
"like-ar": "^0.3.
|
|
51
|
+
"like-ar": "^0.3.7",
|
|
52
52
|
"login-plus": "^1.7.0",
|
|
53
53
|
"memorystore": "^1.6.7",
|
|
54
54
|
"mini-tools": "^1.11.2",
|
|
@@ -82,7 +82,7 @@
|
|
|
82
82
|
"@types/js-yaml": "^4.0.5",
|
|
83
83
|
"@types/mocha": "^10.0.1",
|
|
84
84
|
"@types/multiparty": "~0.0.33",
|
|
85
|
-
"@types/node": "^18.
|
|
85
|
+
"@types/node": "^18.14.1",
|
|
86
86
|
"@types/nodemailer": "^6.4.7",
|
|
87
87
|
"@types/numeral": "~2.0.2",
|
|
88
88
|
"@types/session-file-store": "^1.2.2",
|
|
@@ -99,7 +99,7 @@
|
|
|
99
99
|
"kill-9": "~0.4.3",
|
|
100
100
|
"mocha": "^10.2.0",
|
|
101
101
|
"nyc": "^15.1.0",
|
|
102
|
-
"puppeteer": "^19.
|
|
102
|
+
"puppeteer": "^19.7.2",
|
|
103
103
|
"sinon": "^15.0.1",
|
|
104
104
|
"supertest": "^6.3.3",
|
|
105
105
|
"types.d.ts": "~0.6.11",
|