tuain-form-manager 1.4.7 → 1.4.8

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.
@@ -151,6 +151,18 @@ class FormManager {
151
151
  errorObj = this.errMgr.get(modErrs.formActionExec.formNotFound, message);
152
152
  return [errorObj, null];
153
153
  }
154
+ const requireSession = formDefinition.form.requireSession ?? false;
155
+ if (requireSession) {
156
+ const { currentSession } = requestContext ?? {};
157
+ const { sessionDetail } = currentSession ?? {};
158
+ if (!currentSession || !sessionDetail) {
159
+ // El formulario requiere de la existencia de una sesión
160
+ message = `No existe una sesión válida para procesar la solicitud del formulario ${formCode}`;
161
+ this.logger.log({ level: 'error', label: 'FormManager', action: 'executeFormAction', message });
162
+ errorObj = this.errMgr.get(modErrs.formActionExec.sessionNotFound, message);
163
+ return [errorObj, null];
164
+ }
165
+ }
154
166
  [errorObj, resultForm] = await formCustomObject.executeFormAction(actionCode);
155
167
  message = `END FORM ACTION ${formCode} / ${actionCode} / ${errorObj?.errorCode ?? ''}`;
156
168
  this.logger.log({ level: 'info', label: 'FormManager', action: 'executeFormAction', message });
package/lib/form.js CHANGED
@@ -162,6 +162,7 @@ class Form {
162
162
  set currentMode(state) { this.state = state; }
163
163
 
164
164
  get formCode() { return this._formDefinition.form.formCode; }
165
+ get requireSession() { return this._formDefinition.form.requireSession ?? false; }
165
166
  get globalFunctions() { return this._formDefinition?.bussinesFunctionsRequired ?? []; }
166
167
  get responseData() { return this._responseData; }
167
168
  set returnedFile(fileContent) { this._responseData.returnedFile = fileContent; }
@@ -8,6 +8,7 @@ module.exports = {
8
8
  formNotFound: ['01', 'Formulario no encontrado', 404],
9
9
  actionNotDefined: ['02', 'Acción no definida', 404],
10
10
  exceptionNotHandled: ['03', 'Excepción no controlada', 400],
11
+ sessionNotFound: ['04', 'Excepción no controlada', 400],
11
12
  },
12
13
  fieldValidation: {
13
14
  NoValidationCallback: ['01', 'Función de validación no existe', 405],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tuain-form-manager",
3
- "version": "1.4.7",
3
+ "version": "1.4.8",
4
4
  "description": "Component library to perform operations on Tuain Development Framework forms to interchange information on web or mobile applications based on the data interchange of abstract forms making trnasformation on the data upon actions required on both sides (front and back)",
5
5
  "main": "index.js",
6
6
  "scripts": {