backend-plus 2.0.0-rc.12 → 2.0.0-rc.14
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 +122 -4
- package/lib/backend-plus.js +36 -24
- package/package.json +12 -12
package/lib/backend-plus.d.ts
CHANGED
|
@@ -12,9 +12,7 @@ export type LangId = 'en'|'es'|'etc...';
|
|
|
12
12
|
|
|
13
13
|
export type Server=net.Server;
|
|
14
14
|
|
|
15
|
-
export
|
|
16
|
-
[key:string]: any
|
|
17
|
-
}
|
|
15
|
+
export type CoreFunctionParameters<T extends Record<string, any>> = T;
|
|
18
16
|
|
|
19
17
|
export type MarkdownDoc = 'markdown documentation with `` can content newlines. The identation of the first line is deleted in all others'|'etc...';
|
|
20
18
|
|
|
@@ -365,6 +363,126 @@ export interface Caches {
|
|
|
365
363
|
procedures:Record<string, {timestamp:number, result:any}>
|
|
366
364
|
}
|
|
367
365
|
|
|
366
|
+
export interface AppConfigBin { // executables in SO
|
|
367
|
+
"zip-password-parameter-flag": string // parameter to pass the password to the zipper
|
|
368
|
+
"zip-password-prefix": string // password prefix
|
|
369
|
+
"zip-fixed-parameters":string // fixed parameters to pass to zipper
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
export interface AppConfig {
|
|
373
|
+
server: {
|
|
374
|
+
"base-url": string // rool path in the url
|
|
375
|
+
port: number // port of the API services
|
|
376
|
+
"session-store": string // strategies to store session info
|
|
377
|
+
"ip-replacer": string // ip that can be not showed or deduced in logs
|
|
378
|
+
"silent-startup": boolean // less logs when startup
|
|
379
|
+
"kill-9": string // a way to kill from URL with a token
|
|
380
|
+
bitacoraSchema: string
|
|
381
|
+
bitacoraTableName: string
|
|
382
|
+
}
|
|
383
|
+
db: {
|
|
384
|
+
motor: 'postgresql'
|
|
385
|
+
database: string
|
|
386
|
+
user: string
|
|
387
|
+
password: string
|
|
388
|
+
schema: string
|
|
389
|
+
search_path: string
|
|
390
|
+
tablespace: string // for creation scripts
|
|
391
|
+
"min-version": string // min version of the motor needed
|
|
392
|
+
nodb: boolean // if there is no database needed in the app
|
|
393
|
+
no_login: boolean // if no login is needed. Used only for all public sites
|
|
394
|
+
"downloadable-backup-path": string // OS path of the encrypted downloadable backup
|
|
395
|
+
}
|
|
396
|
+
login: {
|
|
397
|
+
schema: string // schema of the user table
|
|
398
|
+
table: string // user table
|
|
399
|
+
userFieldname: string // fieldname in user table that stores the user name
|
|
400
|
+
passFieldname: string // fieldname in user table that stores the password hash
|
|
401
|
+
rolFieldname: string // fieldname in user table that stores the rol
|
|
402
|
+
unloggedLandPage: string // land page when there is no user logged when the backend has public services
|
|
403
|
+
noLoggedUrlPath: string // path of non logged users when the backend has no public services
|
|
404
|
+
"preserve-case": boolean // preserve the case of the user name
|
|
405
|
+
activeClausule: string // SQL expression over the user table to check if a user is active
|
|
406
|
+
lockedClausule: string // SQL expression over the user table to check if a user is locked
|
|
407
|
+
disableChangePassword: boolean // disallow password change
|
|
408
|
+
skipBitacora: boolean // don't register logins
|
|
409
|
+
keepAlive: number // secs to keep alive a session if only keep alive request where received
|
|
410
|
+
plus: {
|
|
411
|
+
userFieldName:string
|
|
412
|
+
store:{
|
|
413
|
+
module: string
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
forget: { // forget password configurations:
|
|
417
|
+
urlPath: string // url sent by mail. default: `/new-pass`
|
|
418
|
+
urlPathOk: string // confirmation page
|
|
419
|
+
mailFields: string[] // fields for the forget pass mail
|
|
420
|
+
|
|
421
|
+
}
|
|
422
|
+
"double-dragon": boolean // app user must match db user
|
|
423
|
+
}
|
|
424
|
+
install: {
|
|
425
|
+
"table-data-dir": string // SO path to the .tab files in the db creation script
|
|
426
|
+
dump: { // configuration of --dump-db, the db creation script
|
|
427
|
+
"drop-his": boolean // include drop schema his in the db creation script
|
|
428
|
+
db: {
|
|
429
|
+
owner: string
|
|
430
|
+
extensions: string[] // extensions to be installed (gist, pg_trgm, pgcrypto)
|
|
431
|
+
enances: 'file' // if the enances must be dumped in a separate file
|
|
432
|
+
// from here info to set the owner and replace owner and user used in devel when script creation
|
|
433
|
+
"owner4special-scripts": string
|
|
434
|
+
"user4special-scripts": string
|
|
435
|
+
"apply-generic-user-replaces": string
|
|
436
|
+
}
|
|
437
|
+
"admin-can-create-tables": boolean // for apps that allows the user to create tables
|
|
438
|
+
"skip-content": boolean // don't create data from "table-data-dir"
|
|
439
|
+
folders: string //
|
|
440
|
+
scripts: {
|
|
441
|
+
prepare: string // SO path to the prepare scripts that will be run before the functions creations and inserts
|
|
442
|
+
"post-adapt": string // SO path to the post-adapt scripts that will be run after data inserts (of .tab tables)
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
"client-setup": { // front-end config
|
|
447
|
+
title:string // title of the app (common sufix of the title bar)
|
|
448
|
+
}
|
|
449
|
+
log: {
|
|
450
|
+
"serve-content": never
|
|
451
|
+
req: {
|
|
452
|
+
"keep-alive": boolean
|
|
453
|
+
}
|
|
454
|
+
db: {
|
|
455
|
+
"last-error": boolean // store last db error in a log file
|
|
456
|
+
devel: boolean //
|
|
457
|
+
"on-demand": string // if log db level can be changed on the fly
|
|
458
|
+
until: string | Date // full log until...
|
|
459
|
+
results: boolean // if query results must be included in full db logs
|
|
460
|
+
}
|
|
461
|
+
session: boolean // if all session activity must be logged
|
|
462
|
+
}
|
|
463
|
+
devel: {
|
|
464
|
+
delay: number // msec avg random delay in API responses (to emulate slow nets)
|
|
465
|
+
"cache-content": boolean // if the cache header must be sent to the client (when no devel config the default is true)
|
|
466
|
+
forceShowAsEditable: boolean // force "editable" behavior in grids
|
|
467
|
+
}
|
|
468
|
+
mailer: { // config to send mails
|
|
469
|
+
conn: string // connection string
|
|
470
|
+
"mail-info": {} // static mail config
|
|
471
|
+
supervise: {
|
|
472
|
+
to: string // email addres of the supervisor
|
|
473
|
+
event: {
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
bin: AppConfigBin
|
|
478
|
+
data: {
|
|
479
|
+
transformers: {
|
|
480
|
+
text: string // define the inputTransformers for text comming from the fron-end via the API
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
skipUnknownFieldsAtImport: boolean // if unknown fields must be skipped by default in import
|
|
484
|
+
}
|
|
485
|
+
|
|
368
486
|
export class AppBackend{
|
|
369
487
|
procedures:ProcedureDef[]
|
|
370
488
|
procedure:{ [key:string]:ProcedureDef }
|
|
@@ -372,7 +490,7 @@ export class AppBackend{
|
|
|
372
490
|
getTableDefinition: TableDefinitionsGetters
|
|
373
491
|
tableStructures: TableDefinitions
|
|
374
492
|
db: MotorDb
|
|
375
|
-
config:
|
|
493
|
+
config: AppConfig
|
|
376
494
|
rootPath: string
|
|
377
495
|
caches:Caches
|
|
378
496
|
fieldDomain:{[k:string]:Partial<FieldDefinition>}
|
package/lib/backend-plus.js
CHANGED
|
@@ -2878,8 +2878,14 @@ AppBackend.prototype.dumpDbSchemaPartial = async function dumpDbSchemaPartial(pa
|
|
|
2878
2878
|
if (err.code != 'ENOENT') throw err;
|
|
2879
2879
|
try {
|
|
2880
2880
|
var allTableContent = await fs.readFile('install/local-dump.psql','utf-8');
|
|
2881
|
-
var startIndex = allTableContent.
|
|
2882
|
-
|
|
2881
|
+
var startIndex = allTableContent.indexOf('-- Data for Name: ');
|
|
2882
|
+
console.log('startIndex', startIndex);
|
|
2883
|
+
var lastUseful = allTableContent.lastIndexOf('\nSELECT pg_catalog.setval')
|
|
2884
|
+
console.log('lastUseful', lastUseful);
|
|
2885
|
+
if (lastUseful == -1) lastUseful = allTableContent.lastIndexOf('\n\\.\n');
|
|
2886
|
+
console.log('lastUseful', lastUseful);
|
|
2887
|
+
var lastIndex = allTableContent.indexOf('\n--', lastUseful);
|
|
2888
|
+
console.log('lastIndex', lastIndex);
|
|
2883
2889
|
allTableData = allTableContent.slice(startIndex, lastIndex);
|
|
2884
2890
|
} catch(err) {
|
|
2885
2891
|
if (err.code != 'ENOENT') throw err;
|
|
@@ -3003,27 +3009,33 @@ AppBackend.prototype.dumpDbSchemaPartial = async function dumpDbSchemaPartial(pa
|
|
|
3003
3009
|
}
|
|
3004
3010
|
let installFolders = be.config.install.dump.folders ?? ['install']
|
|
3005
3011
|
let texts = await Promise.all(
|
|
3006
|
-
[
|
|
3007
|
-
|
|
3008
|
-
|
|
3009
|
-
|
|
3010
|
-
|
|
3012
|
+
[
|
|
3013
|
+
['prepare.sql'],
|
|
3014
|
+
['pre-adapt.sql'].concat(be.config.install.dump.scripts['pre-adapt']),
|
|
3015
|
+
['adapt.sql'],
|
|
3016
|
+
be.config.install.dump.scripts['prepare'] ?? [],
|
|
3017
|
+
be.config.install.dump.scripts['post-adapt'] ?? []
|
|
3018
|
+
]
|
|
3019
|
+
.map(async function(fileNames){
|
|
3020
|
+
if (!fileNames) return '';
|
|
3011
3021
|
var i = 0;
|
|
3012
|
-
|
|
3013
|
-
|
|
3014
|
-
|
|
3015
|
-
|
|
3016
|
-
|
|
3017
|
-
|
|
3018
|
-
|
|
3019
|
-
|
|
3020
|
-
|
|
3021
|
-
|
|
3022
|
-
|
|
3023
|
-
|
|
3024
|
-
|
|
3025
|
-
|
|
3026
|
-
|
|
3022
|
+
return (await Promise.all(fileNames.map(async fileName => {
|
|
3023
|
+
var content;
|
|
3024
|
+
do {
|
|
3025
|
+
var folder = installFolders[i];
|
|
3026
|
+
try{
|
|
3027
|
+
content = await fs.readFile(be.rootPath+'/'+folder+'/'+fileName, {encoding:'UTF8'});
|
|
3028
|
+
} catch (err) {
|
|
3029
|
+
if(err.code!='ENOENT') throw err;
|
|
3030
|
+
}
|
|
3031
|
+
i++;
|
|
3032
|
+
} while (i < installFolders.length && !content);
|
|
3033
|
+
if (!content) {
|
|
3034
|
+
return '-- no '+fileName+'\n';
|
|
3035
|
+
} else {
|
|
3036
|
+
return '-- '+folder+'/'+fileName+'\n'+content;
|
|
3037
|
+
};
|
|
3038
|
+
}))).join('\n')
|
|
3027
3039
|
})
|
|
3028
3040
|
);
|
|
3029
3041
|
|
|
@@ -3053,7 +3065,7 @@ AppBackend.prototype.dumpDbSchemaPartial = async function dumpDbSchemaPartial(pa
|
|
|
3053
3065
|
'\n-- common'+
|
|
3054
3066
|
common+'\n'+
|
|
3055
3067
|
(complete? '\n\n--prepare.sql\n'+ texts[0]+'\n\n' :'' )+
|
|
3056
|
-
(complete? texts
|
|
3068
|
+
(complete? texts[3] + '\n\n' : '' )+
|
|
3057
3069
|
'\n-- functions\n' + functionLines.join('\n')+
|
|
3058
3070
|
'\n-- lines \n' + lines.join('\n')+
|
|
3059
3071
|
(complete? ('\n\n-- pre-ADAPTs\n'+texts[1]+'\n\n') : '' )+
|
|
@@ -3063,7 +3075,7 @@ AppBackend.prototype.dumpDbSchemaPartial = async function dumpDbSchemaPartial(pa
|
|
|
3063
3075
|
'\n-- FKs\n' + fkLines.join('\n')+
|
|
3064
3076
|
'\n-- index\n' + indexLines.join('\n')+
|
|
3065
3077
|
'\n-- policies\n' + policyLines.join('\n')+
|
|
3066
|
-
(complete? texts
|
|
3078
|
+
(complete? texts[4] + '\n\n' : '' )+
|
|
3067
3079
|
(complete? (be.config.install.dump.enances==='inline'?enancePart:'') :'')
|
|
3068
3080
|
).replace(/\uFEFF/g /*inner BOM replacing*/,'\n\n').replace(
|
|
3069
3081
|
new RegExp(escapeRegExp(db.quoteIdent(be.config.install.dump.db["owner4special-scripts"])),'g'),
|
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.14",
|
|
5
5
|
"author": "Codenautas <codenautas@googlegroups.com>",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"repository": "codenautas/backend-plus",
|
|
@@ -30,16 +30,16 @@
|
|
|
30
30
|
],
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"@upgraded/locate-path": "^6.0.0-alfa.1",
|
|
33
|
-
"ajax-best-promise": "^0.4.
|
|
33
|
+
"ajax-best-promise": "^0.4.2",
|
|
34
34
|
"backend-skins": "^0.1.15",
|
|
35
35
|
"best-globals": "^1.1.4",
|
|
36
36
|
"big.js": "^6.2.1",
|
|
37
37
|
"body-parser": "^1.20.2",
|
|
38
38
|
"cast-error": "^0.1.1",
|
|
39
|
-
"castellano": "^0.1.
|
|
39
|
+
"castellano": "^0.1.4",
|
|
40
40
|
"connect-pg-simple": "^9.0.1",
|
|
41
41
|
"cookie-parser": "^1.4.6",
|
|
42
|
-
"dialog-promise": "^0.
|
|
42
|
+
"dialog-promise": "^0.10.0",
|
|
43
43
|
"discrepances": "^0.2.8",
|
|
44
44
|
"express": "^4.19.2",
|
|
45
45
|
"express-session": "^1.18.0",
|
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
"read-yaml-promise": "^1.0.2",
|
|
64
64
|
"regexplicit": "^0.1.3",
|
|
65
65
|
"require-bro": "^0.3.1",
|
|
66
|
-
"self-explain": "^0.
|
|
66
|
+
"self-explain": "^0.11.0",
|
|
67
67
|
"serve-content": "^0.3.19",
|
|
68
68
|
"session-file-store": "^1.5.0",
|
|
69
69
|
"sql-tools": "^0.1.2",
|
|
@@ -71,7 +71,7 @@
|
|
|
71
71
|
"stylus": "0.63.0",
|
|
72
72
|
"type-store": "^0.4.1",
|
|
73
73
|
"typed-controls": "^0.12.0",
|
|
74
|
-
"xlsx": "https://cdn.sheetjs.com/xlsx-0.
|
|
74
|
+
"xlsx": "https://cdn.sheetjs.com/xlsx-0.20.2/xlsx-0.20.2.tgz"
|
|
75
75
|
},
|
|
76
76
|
"devDependencies": {
|
|
77
77
|
"@types/big.js": "^6.2.2",
|
|
@@ -82,8 +82,8 @@
|
|
|
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.12.
|
|
86
|
-
"@types/nodemailer": "^6.4.
|
|
85
|
+
"@types/node": "^20.12.11",
|
|
86
|
+
"@types/nodemailer": "^6.4.15",
|
|
87
87
|
"@types/numeral": "~2.0.5",
|
|
88
88
|
"@types/session-file-store": "^1.2.5",
|
|
89
89
|
"@types/stack-trace": "~0.0.33",
|
|
@@ -99,11 +99,11 @@
|
|
|
99
99
|
"kill-9": "~0.4.3",
|
|
100
100
|
"mocha": "^10.4.0",
|
|
101
101
|
"nyc": "^15.1.0",
|
|
102
|
-
"puppeteer": "^22.
|
|
103
|
-
"sinon": "^17.0.
|
|
104
|
-
"supertest": "^
|
|
102
|
+
"puppeteer": "^22.8.0",
|
|
103
|
+
"sinon": "^17.0.2",
|
|
104
|
+
"supertest": "^7.0.0",
|
|
105
105
|
"types.d.ts": "~0.6.21",
|
|
106
|
-
"typescript": "^5.4.
|
|
106
|
+
"typescript": "^5.4.5",
|
|
107
107
|
"why-is-node-running": "^2.2.2"
|
|
108
108
|
},
|
|
109
109
|
"engines": {
|