tuain-form-manager 1.4.11 → 1.4.20

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/.eslintignore ADDED
@@ -0,0 +1 @@
1
+ public/*
package/.eslintrc.js CHANGED
@@ -1,17 +1,17 @@
1
1
  module.exports = {
2
2
  env: {
3
- browser: true,
3
+ browser: false,
4
4
  commonjs: true,
5
5
  es2021: true,
6
6
  },
7
- extends: [
8
- 'airbnb-base',
9
- ],
7
+ extends: ['airbnb-base'],
10
8
  parserOptions: {
11
9
  ecmaVersion: 12,
12
10
  },
13
11
  rules: {
12
+ 'prettier/prettier': 'error',
14
13
  'consistent-return': 'off',
14
+ 'no-unused-expressions': 'off',
15
15
  'no-plusplus': 0,
16
16
  'no-continue': 0,
17
17
  radix: 0,
@@ -19,23 +19,58 @@ module.exports = {
19
19
  'no-await-in-loop': 0,
20
20
  'no-use-before-define': 0,
21
21
  'no-param-reassign': 0,
22
- 'max-len': ['error', 120, 2, {
23
- ignoreUrls: true,
24
- ignoreComments: true,
25
- ignoreRegExpLiterals: true,
26
- ignoreStrings: true,
27
- ignoreTemplateLiterals: true,
28
- }],
29
- 'object-curly-newline': ['error', {
30
- ObjectPattern: { multiline: true },
31
- ImportDeclaration: 'never',
32
- ExportDeclaration: { multiline: true, minProperties: 3 },
33
- }],
34
- 'lines-between-class-members': ['error', 'always', {
35
- exceptAfterSingleLine: true,
36
- }],
37
- 'arrow-parens': ['error', 'as-needed', {
38
- requireForBlockBody: true,
39
- }],
22
+ 'comma-spacing': ['error', { before: false, after: true }],
23
+ 'max-len': [
24
+ 'error',
25
+ 130,
26
+ 2,
27
+ {
28
+ ignoreUrls: true,
29
+ ignoreComments: true,
30
+ ignoreRegExpLiterals: true,
31
+ ignoreStrings: true,
32
+ ignoreTemplateLiterals: true,
33
+ },
34
+ ],
35
+ 'object-property-newline': ['error', { allowMultiplePropertiesPerLine: true }],
36
+ 'no-extra-parens': [
37
+ 'error',
38
+ 'all',
39
+ {
40
+ nestedBinaryExpressions: false,
41
+ enforceForArrowConditionals: false,
42
+ enforceForNewInMemberExpressions: false,
43
+ enforceForSequenceExpressions: false,
44
+ ignoreJSX: 'all',
45
+ conditionalAssign: false,
46
+ returnAssign: false,
47
+ },
48
+ ],
49
+ 'multiline-ternary': ['error', 'never'],
50
+ 'object-curly-newline': [
51
+ 'error',
52
+ {
53
+ ObjectPattern: { multiline: true },
54
+ ImportDeclaration: 'never',
55
+ ExportDeclaration: { multiline: true, minProperties: 3 },
56
+ },
57
+ ],
58
+ 'lines-between-class-members': [
59
+ 'error',
60
+ 'always',
61
+ {
62
+ exceptAfterSingleLine: true,
63
+ },
64
+ ],
65
+ 'arrow-parens': [
66
+ 'error',
67
+ 'as-needed',
68
+ {
69
+ requireForBlockBody: true,
70
+ },
71
+ ],
72
+ 'function-paren-newline': ['error', 'consistent'],
73
+ 'function-call-argument-newline': 'off',
40
74
  },
75
+ plugins: ['prettier'],
41
76
  };
package/.prettierrc ADDED
@@ -0,0 +1,21 @@
1
+ {
2
+ "singleQuote": true,
3
+ "semi": true,
4
+ "printWidth": 130,
5
+ "trailingComma": "all",
6
+ "bracketSpacing": true,
7
+ "arrowParens": "always",
8
+ "singleAttributePerLine": false,
9
+ "overrides": [
10
+ {
11
+ "files": [
12
+ "**/*.css",
13
+ "**/*.scss",
14
+ "**/*.html"
15
+ ],
16
+ "options": {
17
+ "singleQuote": false
18
+ }
19
+ }
20
+ ]
21
+ }
@@ -0,0 +1,9 @@
1
+ import globals from "globals";
2
+ import pluginJs from "@eslint/js";
3
+
4
+
5
+ export default [
6
+ {files: ["**/*.js"], languageOptions: {sourceType: "commonjs"}},
7
+ {languageOptions: { globals: globals.browser }},
8
+ pluginJs.configs.recommended,
9
+ ];
@@ -103,7 +103,7 @@ class FormManager {
103
103
  if (modifiedFormDef?.fields) {
104
104
  for (let index = 0; index < modifiedFormDef?.fields?.length; index++) {
105
105
  const modifiedField = modifiedFormDef?.fields[index];
106
- const currentField = formDefinition.fields.find(fld => fld.fieldCode === modifiedField.fieldCode);
106
+ const currentField = formDefinition.fields.find((fld) => fld.fieldCode === modifiedField.fieldCode);
107
107
  Object.assign(currentField, modifiedField);
108
108
  }
109
109
  }
@@ -118,7 +118,12 @@ class FormManager {
118
118
  const formDefinition = this.getFormFlatDefinition(formCode);
119
119
  if (!formDefinition) {
120
120
  message = `Definición de formulario ${formCode} no encontrada`;
121
- this.logger.log({ level: 'error', label: 'FormManager', action: 'executeFormAction', message });
121
+ this.logger.log({
122
+ level: 'error',
123
+ label: 'FormManager',
124
+ action: 'executeFormAction',
125
+ message,
126
+ });
122
127
  errorObj = this.errMgr.get(modErrs.formActionExec.formNotFound, message);
123
128
  return [errorObj, null];
124
129
  }
@@ -129,10 +134,15 @@ class FormManager {
129
134
  } else {
130
135
  const { formMapping, formClassDirectory } = this.formsDefinitions;
131
136
  const classFileName = formMapping?.[formCode]?.class ?? this.formsDefinitions?.[formCode]?.classFile;
132
- const moduleName = (classFileName) ? path.resolve(this.rootPath, formClassDirectory ?? '', classFileName) : '';
137
+ const moduleName = classFileName ? path.resolve(this.rootPath, formClassDirectory ?? '', classFileName) : '';
133
138
  if (!moduleName) {
134
139
  message = `No existe nombre de archivo para el componente de gestión formulario ${formCode}`;
135
- this.logger.log({ level: 'error', label: 'FormManager', action: 'executeFormAction', message });
140
+ this.logger.log({
141
+ level: 'error',
142
+ label: 'FormManager',
143
+ action: 'executeFormAction',
144
+ message,
145
+ });
136
146
  errorObj = this.errMgr.get(modErrs.formActionExec.formNotFound, message);
137
147
  return [errorObj, null];
138
148
  }
@@ -140,7 +150,12 @@ class FormManager {
140
150
  }
141
151
  if (!FormClass) {
142
152
  message = `No se encontró componente para la atenciónn del formulario ${formCode}`;
143
- this.logger.log({ level: 'error', label: 'FormManager', action: 'executeFormAction', message });
153
+ this.logger.log({
154
+ level: 'error',
155
+ label: 'FormManager',
156
+ action: 'executeFormAction',
157
+ message,
158
+ });
144
159
  errorObj = this.errMgr.get(modErrs.formActionExec.formNotFound, message);
145
160
  return [errorObj, null];
146
161
  }
@@ -151,26 +166,49 @@ class FormManager {
151
166
  if (!currentSession || !sessionDetail) {
152
167
  // El formulario requiere de la existencia de una sesión
153
168
  message = `No existe una sesión válida para procesar la solicitud del formulario ${formCode}`;
154
- this.logger.log({ level: 'error', label: 'FormManager', action: 'executeFormAction', message });
169
+ this.logger.log({
170
+ level: 'error',
171
+ label: 'FormManager',
172
+ action: 'executeFormAction',
173
+ message,
174
+ });
155
175
  errorObj = this.errMgr.get(modErrs.formActionExec.sessionNotFound, message);
156
176
  return [errorObj, null];
157
177
  }
178
+ console.log('Se requiere sesión y si se tiene, sessionDetail:...');
179
+ console.log(sessionDetail);
158
180
  }
159
181
  const formCustomObject = new FormClass(this.logger, this.errMgr, requestContext, formDefinition, requestData);
160
182
  if (!formCustomObject) {
161
183
  message = `No fue posible instanciar la clase de gestión del formulario ${formCode}`;
162
- this.logger.log({ level: 'error', label: 'FormManager', action: 'executeFormAction', message });
184
+ this.logger.log({
185
+ level: 'error',
186
+ label: 'FormManager',
187
+ action: 'executeFormAction',
188
+ message,
189
+ });
163
190
  errorObj = this.errMgr.get(modErrs.formActionExec.formNotFound, message);
164
191
  return [errorObj, null];
165
192
  }
166
193
  [errorObj, resultForm] = await formCustomObject.executeFormAction(actionCode);
167
194
  message = `END FORM ACTION ${formCode} / ${actionCode} / ${errorObj?.errorCode ?? ''}`;
168
- this.logger.log({ level: 'info', label: 'FormManager', action: 'executeFormAction', message });
195
+ this.logger.log({
196
+ level: 'info',
197
+ label: 'FormManager',
198
+ action: 'executeFormAction',
199
+ message,
200
+ });
169
201
  return [errorObj, resultForm];
170
202
  } catch (err) {
171
- message = `Excepción no controlada: ${err.message}\n${err.stack}`
172
- + `------ END BY EXCEPTION FORM ACTION ${formCode} / ${actionCode} ------`;
173
- this.logger.log({ level: 'error', label: 'FormManager', action: 'executeFormAction', message });
203
+ message =
204
+ `Excepción no controlada: ${err.message}\n${err.stack}` +
205
+ `------ END BY EXCEPTION FORM ACTION ${formCode} / ${actionCode} ------`;
206
+ this.logger.log({
207
+ level: 'error',
208
+ label: 'FormManager',
209
+ action: 'executeFormAction',
210
+ message,
211
+ });
174
212
  errorObj = this.errMgr.get(modErrs.formActionExec.formNotFound, message);
175
213
  return [errorObj, null];
176
214
  }
package/lib/form.js CHANGED
@@ -490,7 +490,8 @@ class Form {
490
490
  } else {
491
491
  fieldOptionValue = optionObj?.[valueField];
492
492
  }
493
- if (fieldOptionId && fieldOptionValue !== undefined && fieldOptionValue !== null) {
493
+ if (fieldOptionId !== undefined && fieldOptionId !== null
494
+ && fieldOptionValue !== undefined && fieldOptionValue !== null) {
494
495
  fieldObject.fieldOptions.push({ fieldOptionId, fieldOptionValue });
495
496
  }
496
497
  }
@@ -1,26 +1,26 @@
1
1
  module.exports = {
2
2
  getFormDefinition: {
3
- formNotFound: ['01', 'Formulario no encontrado', 404],
4
- formNotAllowed: ['02', 'Formulario no autorizado', 403],
5
- formPopulateFail: ['03', 'Error en la ejecución inicial de personalización', 400],
3
+ formNotFound: ['1001', 'Formulario no encontrado', 404],
4
+ formNotAllowed: ['1002', 'Formulario no autorizado', 403],
5
+ formPopulateFail: ['1003', 'Error en la ejecución inicial de personalización', 400],
6
6
  },
7
7
  formActionExec: {
8
- formNotFound: ['01', 'Formulario no encontrado', 404],
9
- actionNotDefined: ['02', 'Acción no definida', 404],
10
- exceptionNotHandled: ['03', 'Excepción no controlada', 400],
11
- sessionNotFound: ['04', 'Excepción no controlada', 400],
8
+ formNotFound: ['1001', 'Formulario no encontrado', 404],
9
+ actionNotDefined: ['1002', 'Acción no definida', 404],
10
+ exceptionNotHandled: ['1003', 'Excepción no controlada', 400],
11
+ sessionNotFound: ['1004', 'No existe sesión para procesar el formulario', 400],
12
12
  },
13
13
  fieldValidation: {
14
- NoValidationCallback: ['01', 'Función de validación no existe', 405],
15
- exceptionNotHandled: ['02', 'Excepción no controlada', 400],
14
+ NoValidationCallback: ['1001', 'Función de validación no existe', 405],
15
+ exceptionNotHandled: ['1002', 'Excepción no controlada', 400],
16
16
  },
17
17
  tableActionExec: {
18
- subjectIncomplete: ['01', 'El sujeto de la acción de tabla no contiene toda la información requerida', 400],
19
- noRecordId: ['02', 'El sujeto de la acción de tabla no contiene identificador del registro', 400],
20
- noCallback: ['03', 'No existe función callback para la acción de la tabla', 405],
18
+ subjectIncomplete: ['1001', 'El sujeto de la acción de tabla no contiene toda la información requerida', 400],
19
+ noRecordId: ['1002', 'El sujeto de la acción de tabla no contiene identificador del registro', 400],
20
+ noCallback: ['1003', 'No existe función callback para la acción de la tabla', 405],
21
21
  },
22
22
  tablePopulate: {
23
- subjectIncomplete: ['01', 'El sujeto de la acción de poblado de tabla no contiene toda la información requerida', 400],
24
- exceptionNotHandled: ['99', 'Excepción no controlada', 400],
23
+ subjectIncomplete: ['1001', 'El sujeto de la acción de poblado de tabla no contiene toda la información requerida', 400],
24
+ exceptionNotHandled: ['1099', 'Excepción no controlada', 400],
25
25
  },
26
26
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tuain-form-manager",
3
- "version": "1.4.11",
3
+ "version": "1.4.20",
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": {
@@ -21,8 +21,9 @@
21
21
  "license": "MIT",
22
22
  "homepage": "https://bitbucket.org/imixconsulting/tuain_form_manager#readme",
23
23
  "devDependencies": {
24
- "eslint": "^7.32.0",
25
- "eslint-config-airbnb-base": "^14.2.1",
26
- "eslint-plugin-import": "^2.24.2"
24
+ "@eslint/js": "^9.7.0",
25
+ "chai": "^4.3.3",
26
+ "eslint": "^9.7.0",
27
+ "eslint-config-prettier": "^9.1.0"
27
28
  }
28
29
  }