backend-plus 2.5.2-betha.14 → 2.5.2-betha.15
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-tables.js +3 -0
- package/lib/backend-plus.d.ts +2 -1
- package/lib/backend-plus.js +14 -7
- package/package.json +2 -2
package/for-client/my-tables.js
CHANGED
|
@@ -2203,6 +2203,9 @@ myOwn.specialDefaultValue={
|
|
|
2203
2203
|
return belowDepot.row[fieldName]?belowDepot.row[fieldName]+1:(
|
|
2204
2204
|
aboveDepot.row[fieldName]?aboveDepot.row[fieldName]-1:1
|
|
2205
2205
|
);
|
|
2206
|
+
},
|
|
2207
|
+
current_user: function specialDefaultValueCurrentUser(){
|
|
2208
|
+
return my.config.username;
|
|
2206
2209
|
}
|
|
2207
2210
|
}
|
|
2208
2211
|
|
package/lib/backend-plus.d.ts
CHANGED
|
@@ -188,6 +188,7 @@ export type FieldDefinition = EditableDbDefinition & {
|
|
|
188
188
|
dbNullable?:boolean /* dbNullable === false is not nullabla at DB level, but not at CLIENT LEVEL */
|
|
189
189
|
defaultValue?:any
|
|
190
190
|
defaultDbValue?:PgKnownDbValues|string
|
|
191
|
+
specialDefaultValue?:string /* keyof myOwn.specialDefaultValues and/or keyof AppBackend.prototype.specialSqlDefaultExpressions */
|
|
191
192
|
clientSide?:string /* keyof: myOwn.clientSides */
|
|
192
193
|
isName?:boolean|'known' /* is a name but it is a well known name (because the user uses it to thier code or because the code is enugh expresive)
|
|
193
194
|
isPk?:number /* internal: pos in the primaryKey array */
|
|
@@ -204,7 +205,6 @@ export type FieldDefinition = EditableDbDefinition & {
|
|
|
204
205
|
references?:string /* table name */
|
|
205
206
|
referencesField?:string
|
|
206
207
|
aggregate?:'avg'|'sum'|'count'|'min'|'max'|'countTrue' /* keyof myOwn.TableAggregates */
|
|
207
|
-
specialDefaultValue?:string /* keyof myOwn.specialDefaultValues
|
|
208
208
|
defaultForOtherFields?:boolean /* the field that stores the "other fields" of a flexible imported table */
|
|
209
209
|
specialValueWhenInsert?:string
|
|
210
210
|
exportMetadata?:ExportMetadataDefinition
|
|
@@ -548,6 +548,7 @@ export class AppBackend{
|
|
|
548
548
|
dbUserNameExpr:string
|
|
549
549
|
dbUserRolExpr:string
|
|
550
550
|
specialValueWhenInsert:{[k:string]:(context:ProcedureContext, defField:FieldDefinition, parameters:object)=>any}
|
|
551
|
+
specialSqlDefaultExpressions:Record<string, string>
|
|
551
552
|
clearCaches():void
|
|
552
553
|
start(opts?: StartOptions):Promise<void>
|
|
553
554
|
getTables():TableItemDef[]
|
package/lib/backend-plus.js
CHANGED
|
@@ -802,7 +802,7 @@ AppBackend.prototype.start = function start(opts){
|
|
|
802
802
|
}
|
|
803
803
|
}).then(function(client){
|
|
804
804
|
if(username){
|
|
805
|
-
return client.query(`
|
|
805
|
+
return client.query(`CALL set_app_user(${be.db.quoteLiteral(username)})`).execute().then(function(){
|
|
806
806
|
return client;
|
|
807
807
|
});
|
|
808
808
|
}else{
|
|
@@ -1022,7 +1022,7 @@ AppBackend.prototype.start = function start(opts){
|
|
|
1022
1022
|
}
|
|
1023
1023
|
be.getDbClient(req).then(function(cli){
|
|
1024
1024
|
client = cli;
|
|
1025
|
-
return client.query("
|
|
1025
|
+
return client.query("CALL set_app_user('!login')").execute();
|
|
1026
1026
|
}).then(function(){
|
|
1027
1027
|
var infoFieldList=be.config.login.infoFieldList||(be.config.login.rolFieldName?[be.config.login.userFieldName,be.config.login.rolFieldName]:[be.config.login.userFieldName]);
|
|
1028
1028
|
return client.query(
|
|
@@ -1237,6 +1237,10 @@ AppBackend.prototype.specialValueWhenInsert = {
|
|
|
1237
1237
|
}
|
|
1238
1238
|
}
|
|
1239
1239
|
|
|
1240
|
+
AppBackend.prototype.specialSqlDefaultExpressions = {
|
|
1241
|
+
'current_user': 'get_app_user()',
|
|
1242
|
+
}
|
|
1243
|
+
|
|
1240
1244
|
AppBackend.prototype.checkDatabaseStructure = async function checkDatabaseStructure(client){
|
|
1241
1245
|
var be=this;
|
|
1242
1246
|
var result = await client.query(`select setting from pg_settings where name='server_version';`).fetchUniqueValue();
|
|
@@ -2681,8 +2685,12 @@ AppBackend.prototype.dumpDbTableFields = function dumpDbTableFields(tableDef, op
|
|
|
2681
2685
|
fields.push(
|
|
2682
2686
|
' '+db.quoteIdent(fieldDef.name)+
|
|
2683
2687
|
' '+(fieldDef.dataLength?(fieldType=='text'?'varchar':fieldType)+'('+fieldDef.dataLength+')':fieldType)+
|
|
2684
|
-
(fieldDef.
|
|
2685
|
-
|
|
2688
|
+
( be.specialSqlDefaultExpressions[fieldDef.defaultDbValue] != null ? ' default ' + be.specialSqlDefaultExpressions[fieldDef.defaultDbValue]
|
|
2689
|
+
: fieldDef.defaultDbValue != null ? ' default ' + fieldDef.defaultDbValue
|
|
2690
|
+
: be.specialSqlDefaultExpressions[fieldDef.specialDefaultValue] != null ? ' default ' + be.specialSqlDefaultExpressions[fieldDef.specialDefaultValue]
|
|
2691
|
+
: fieldDef.defaultValue != null ? ' default ' + db.quoteLiteral(fieldDef.defaultValue)
|
|
2692
|
+
: ''
|
|
2693
|
+
) +
|
|
2686
2694
|
(be.isGeneratedSequence(fieldDef.sequence)?' generated always as identity':'')+
|
|
2687
2695
|
(fieldDef.generatedAs!=null?` generated always as (${fieldDef.generatedAs}) stored`:'')
|
|
2688
2696
|
);
|
|
@@ -2972,8 +2980,8 @@ AppBackend.prototype.dumpDbSchemaPartial = async function dumpDbSchemaPartial(pa
|
|
|
2972
2980
|
}
|
|
2973
2981
|
}
|
|
2974
2982
|
lines.push(`
|
|
2975
|
-
create or replace
|
|
2976
|
-
security definer
|
|
2983
|
+
create or replace procedure set_app_user(p_user text)
|
|
2984
|
+
security definer language plpgsql
|
|
2977
2985
|
as
|
|
2978
2986
|
$body$
|
|
2979
2987
|
declare
|
|
@@ -3000,7 +3008,6 @@ begin
|
|
|
3000
3008
|
set backend_plus._mode = normal;
|
|
3001
3009
|
end if;
|
|
3002
3010
|
perform set_config('backend_plus._user', p_user, false);
|
|
3003
|
-
return p_user;
|
|
3004
3011
|
end;
|
|
3005
3012
|
$body$;
|
|
3006
3013
|
|
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.5.2-betha.
|
|
4
|
+
"version": "2.5.2-betha.15",
|
|
5
5
|
"author": "Codenautas <codenautas@googlegroups.com>",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"repository": "codenautas/backend-plus",
|
|
@@ -106,7 +106,7 @@
|
|
|
106
106
|
"sinon": "^21.0.0",
|
|
107
107
|
"supertest": "^7.1.4",
|
|
108
108
|
"types.d.ts": "~0.6.22",
|
|
109
|
-
"typescript": "^5.
|
|
109
|
+
"typescript": "^5.9.2",
|
|
110
110
|
"why-is-node-running": "^3.2.2"
|
|
111
111
|
},
|
|
112
112
|
"engines": {
|