6014-executeRoutineMethod #1809

Merged
alexm merged 8 commits from 6014-executeRoutineMethod into dev 2023-11-14 08:45:07 +00:00
Member
No description provided.
alexm added 3 commits 2023-10-23 13:05:12 +00:00
alexm reviewed 2023-10-24 07:19:39 +00:00
@ -0,0 +83,4 @@
schema,
type: type.toUpperCase(),
name: routine,
host: process.env.NODE_ENV ? '' : '%',
Author
Member

He tingut que possar este if, pq en local quan done un grant de host posa '%' i no '' com en produccio.
Ns si sera tema de alguna configuracio de la base de datos local

He provat a possar els grants com developer@'' o developer@`` i res

He tingut que possar este if, pq en local quan done un grant de host posa '%' i no '' com en produccio. Ns si sera tema de alguna configuracio de la base de datos local He provat a possar els grants com developer@'' o `developer`@`` i res
alexm marked this conversation as resolved
alexm reviewed 2023-10-24 07:21:05 +00:00
@ -0,0 +38,4 @@
}
});
Self.executeRoutine = async(ctx, routine, params, schema, type, options) => {
Author
Member

igual se li podria dir execute i jau aixina se queda la url mes curta i s'enten igual.
Applications/myRoutineName/execute
o
Applications/myRoutineName/executeRoutine

igual se li podria dir execute i jau aixina se queda la url mes curta i s'enten igual. Applications/myRoutineName/execute o Applications/myRoutineName/executeRoutine
alexm marked this conversation as resolved
sergiodt reviewed 2023-10-25 07:03:30 +00:00
@ -0,0 +2,4 @@
module.exports = Self => {
Self.remoteMethodCtx('executeRoutine', {
description: 'Return the routes by worker',
Member

Poner bien la descripcion

Poner bien la descripcion
alexm marked this conversation as resolved
alexm reviewed 2023-10-25 12:56:52 +00:00
@ -0,0 +54,4 @@
if (typeof options == 'object')
Object.assign(myOptions, options);
const user = await models.VnUser.findById(userId, {
Author
Member

en vez de comprobar yo si tiene permiso o no. se puede llamar a account.user_hasRoutinePriv que ya te lo comprueba y mejor

en vez de comprobar yo si tiene permiso o no. se puede llamar a account.user_hasRoutinePriv que ya te lo comprueba y mejor
alexm marked this conversation as resolved
jgallego requested changes 2023-11-09 09:15:25 +00:00
@ -0,0 +1,100 @@
const UserError = require('vn-loopback/util/user-error');
module.exports = Self => {
Self.remoteMethodCtx('executeRoutine', {
Owner

crear uno que siga call
un altre function
y un altre intern que tinga el codi comu dels dos

crear uno que siga call un altre function y un altre intern que tinga el codi comu dels dos
alexm marked this conversation as resolved
@ -0,0 +43,4 @@
const models = Self.app.models;
const isFunction = type == 'function';
params = params ?? [];
schema = schema ?? 'vn';
Owner

si no pasan esquema, no usar nada

si no pasan esquema, no usar nada
Author
Member

Gastant user_hasRoutinePriv obliga a passar db

Gastant user_hasRoutinePriv obliga a passar db
@ -0,0 +78,4 @@
const roles = inherits.map(inherit => inherit.inherits().name);
const canExecute = await models.ProcsPriv.findOne({
Owner

Revisar los permisos a nivel global, de esquema y específicos.

Carlosap va gastar user_hasRoutinePriv que ja ho fa, mira de gastar-ho.

Revisar los permisos a nivel global, de esquema y específicos. Carlosap va gastar user_hasRoutinePriv que ja ho fa, mira de gastar-ho.
alexm marked this conversation as resolved
@ -0,0 +92,4 @@
let argString = params.map(() => '?').join(',');
const query = `${caller} ${schema}.${routine}(${argString})`;
Owner

con concatenar valores que vienen del cliente en consultas sql.
usar el ??

con concatenar valores que vienen del cliente en consultas sql. usar el ??
Author
Member

Si posem directe el que ens pasen poden injectar codi

Si posem directe el que ens pasen poden injectar codi
alexm marked this conversation as resolved
sergiodt added 1 commit 2023-11-09 13:03:34 +00:00
gitea/salix/pipeline/head This commit looks good Details
4aac9f93cc
Merge branch 'dev' into 6014-executeRoutineMethod
alexm added 2 commits 2023-11-10 09:58:57 +00:00
alexm changed title from WIP: 6014-executeRoutineMethod to 6014-executeRoutineMethod 2023-11-10 10:28:04 +00:00
alexm requested review from jgallego 2023-11-10 10:28:12 +00:00
alexm reviewed 2023-11-10 10:28:36 +00:00
@ -2355,0 +2355,4 @@
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `account`.`user_hasRoutinePriv`(vType ENUM('PROCEDURE', 'FUNCTION'),
Author
Member

El he tingut que afegir a la estructura

El he tingut que afegir a la estructura
alexm marked this conversation as resolved
jgallego requested changes 2023-11-13 05:50:42 +00:00
@ -0,0 +6,4 @@
const models = Self.app.models;
let caller = 'CALL';
params = params ?? [];
Owner

tota la part comu va en esta funcio.
La part de proc o de func en les respectives.
El resultat es que en esta funció no tindrás ningun if relatiu al tipo

tota la part comu va en esta funcio. La part de proc o de func en les respectives. El resultat es que en esta funció no tindrás ningun if relatiu al tipo
alexm marked this conversation as resolved
alexm added 1 commit 2023-11-13 08:36:18 +00:00
gitea/salix/pipeline/head This commit looks good Details
59d2da24eb
refs #6014 refactor(execute): split code
alexm requested review from jgallego 2023-11-13 08:38:09 +00:00
jgallego requested changes 2023-11-13 09:09:57 +00:00
@ -0,0 +11,4 @@
Object.assign(myOptions, options);
let [caller, chain] = query.split(' ');
if (!chain.includes('.')) chain = 'vn.' + chain;
Owner

quitar esquema por defecto

quitar esquema por defecto
alexm marked this conversation as resolved
@ -0,0 +20,4 @@
if (!Object.values(canExecute)[0]) throw new UserError(`You don't have enough privileges`, 'ACCESS_DENIED');
let argString = params.map(() => '?').join(',');
Owner

const

const
alexm marked this conversation as resolved
@ -0,0 +18,4 @@
{
arg: 'schema',
type: 'string',
description: 'The routine schema',
Owner

required: true,

required: true,
alexm marked this conversation as resolved
@ -0,0 +32,4 @@
});
Self.executeFunc = async(ctx, routine, params, schema, options) => {
if (schema)
Owner

quitar

quitar
alexm marked this conversation as resolved
@ -0,0 +10,4 @@
return {
req: {
accessToken: {userId},
headers: {origin: 'http://localhost'}
Owner

crear redmine para refactor

crear redmine para refactor
alexm marked this conversation as resolved
alexm added 1 commit 2023-11-14 08:17:45 +00:00
gitea/salix/pipeline/head This commit looks good Details
cce61ae8cc
refs #6014 refactor(execute): schema required
alexm requested review from jgallego 2023-11-14 08:17:57 +00:00
jgallego approved these changes 2023-11-14 08:25:39 +00:00
alexm merged commit 12f23fc894 into dev 2023-11-14 08:45:07 +00:00
alexm deleted branch 6014-executeRoutineMethod 2023-11-14 08:45:07 +00:00
Sign in to join this conversation.
No reviewers
No Milestone
No Assignees
3 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: verdnatura/salix#1809
No description provided.