tuain-form-manager 1.4.12 → 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 +1 -0
- package/.eslintrc.js +57 -22
- package/.prettierrc +21 -0
- package/eslint.config.mjs +9 -0
- package/lib/form-manager.js +49 -11
- package/lib/module-errors.js +14 -14
- package/package.json +5 -4
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:
|
|
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
|
-
'
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
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
|
+
}
|
package/lib/form-manager.js
CHANGED
|
@@ -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({
|
|
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 =
|
|
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({
|
|
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({
|
|
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({
|
|
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({
|
|
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({
|
|
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 =
|
|
172
|
-
|
|
173
|
-
|
|
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/module-errors.js
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
module.exports = {
|
|
2
2
|
getFormDefinition: {
|
|
3
|
-
formNotFound: ['
|
|
4
|
-
formNotAllowed: ['
|
|
5
|
-
formPopulateFail: ['
|
|
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: ['
|
|
9
|
-
actionNotDefined: ['
|
|
10
|
-
exceptionNotHandled: ['
|
|
11
|
-
sessionNotFound: ['
|
|
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: ['
|
|
15
|
-
exceptionNotHandled: ['
|
|
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: ['
|
|
19
|
-
noRecordId: ['
|
|
20
|
-
noCallback: ['
|
|
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: ['
|
|
24
|
-
exceptionNotHandled: ['
|
|
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.
|
|
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.
|
|
25
|
-
"
|
|
26
|
-
"eslint
|
|
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
|
}
|