@izara_project/izara-core-generate-service-code 1.0.14 → 1.0.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/package.json +1 -1
- package/src/TemplateData/EndpointPerService/handler/api/template.ejs +22 -8
- package/src/TemplateData/EndpointPerService/mainFunction/create/template.ejs +1 -1
- package/src/TemplateData/EndpointPerService/yaml/template.ejs +2 -2
- package/src/TemplateData/perActionComplete/create/mainFunction/createObjectComplete_main.js +17 -17
package/package.json
CHANGED
|
@@ -15,9 +15,11 @@ You should have received a copy of the GNU Affero General Public License
|
|
|
15
15
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
import {
|
|
19
|
+
middlewareHandler,
|
|
20
|
+
validatorSchema,
|
|
21
|
+
response
|
|
22
|
+
} from '@izara_project/izara-middleware';
|
|
21
23
|
import callingFlowSharedLib from '@izara_project/izara-core-library-calling-flow';
|
|
22
24
|
|
|
23
25
|
//(<optionalRequire>)
|
|
@@ -30,16 +32,28 @@ import <%- action %>Main from './<%- firstLetterUpperCase(action) %>_Main.js'
|
|
|
30
32
|
|
|
31
33
|
//validate event params in middlewareHandler before into main function
|
|
32
34
|
validatorSchema.validateSchemaMiddleware(
|
|
33
|
-
|
|
35
|
+
'<%- action %>',
|
|
34
36
|
//(<validateSchemaSetting>
|
|
35
37
|
//</validateSchemaSetting>)
|
|
36
38
|
)
|
|
39
|
+
|
|
37
40
|
// if need to validate authorizer or additional params , add code to hook tag below
|
|
38
41
|
|
|
42
|
+
let middlewareSettings = { noAuthorizer: <%- action === 'get' ? true : false %> };
|
|
43
|
+
//(<modifyMiddlewareSettings>
|
|
44
|
+
//</modifyMiddlewareSettings>)
|
|
45
|
+
|
|
46
|
+
middlewareHandler.setValidatorSchema(
|
|
47
|
+
{
|
|
48
|
+
//(<additionalValidatorSchema>
|
|
49
|
+
//</additionalValidatorSchema>)
|
|
50
|
+
},
|
|
51
|
+
middlewareSettings
|
|
52
|
+
);
|
|
53
|
+
|
|
39
54
|
//(<afterValidateWith>)
|
|
40
55
|
//(</afterValidateWith>)
|
|
41
56
|
|
|
42
|
-
|
|
43
57
|
export const main = middlewareHandler.wrap(async (event, context) => {
|
|
44
58
|
event._izContext.logger.debug('Event:', event);
|
|
45
59
|
try {
|
|
@@ -54,15 +68,15 @@ export const main = middlewareHandler.wrap(async (event, context) => {
|
|
|
54
68
|
|
|
55
69
|
// return error to client
|
|
56
70
|
if (lambdaFunctionResponse instanceof Error) {
|
|
57
|
-
return
|
|
71
|
+
return response.failure(lambdaFunctionResponse);
|
|
58
72
|
}
|
|
59
73
|
|
|
60
74
|
// return success to client
|
|
61
|
-
return
|
|
75
|
+
return response.success(lambdaFunctionResponse);
|
|
62
76
|
|
|
63
77
|
} catch (err) {
|
|
64
78
|
event._izContext.logger.error('Error, <%- firstLetterUpperCase(action) %>_<%- firstLetterUpperCase(handler) %>: ', err);
|
|
65
|
-
return
|
|
79
|
+
return response.failure(err);
|
|
66
80
|
}
|
|
67
81
|
});
|
|
68
82
|
<%_ function firstLetterUpperCase(text){
|
|
@@ -484,7 +484,7 @@ export default async function createMain(
|
|
|
484
484
|
}; // end loop listOfObjectForCreates
|
|
485
485
|
|
|
486
486
|
if (errorsFound.length > 0) {
|
|
487
|
-
_izContext.logger.debug("Case have
|
|
487
|
+
_izContext.logger.debug("Case have errorsFound:::", errorsFound);
|
|
488
488
|
|
|
489
489
|
// remove awaitingMultipleStep. [[[[[[[open when not test local.]]]]]]]
|
|
490
490
|
await asyncFlowSharedLib.clearAllAwaitingSteps(
|
|
@@ -16,14 +16,14 @@
|
|
|
16
16
|
- httpApi:
|
|
17
17
|
path: /<%- serviceTag %>/<%- resourceApi.event %>/<%- action %>
|
|
18
18
|
method: <%- resourceApi.method %>
|
|
19
|
-
authorizer: authorizerServiceSchema
|
|
20
19
|
#<#<%- firstLetterUpperCase(resourceApi.event) _%><%- firstLetterUpperCase(handlerType) %>AppLevelAuthorizer#>
|
|
20
|
+
# authorizer: authorizerServiceSchema
|
|
21
21
|
#<#/<%- firstLetterUpperCase(resourceApi.event) _%><%- firstLetterUpperCase(handlerType) %>AppLevelAuthorizer#>
|
|
22
22
|
- httpApi:
|
|
23
23
|
path: /<%- serviceTag %>/<%- resourceApi.event %>/<%- action %>/{targetUserId}
|
|
24
24
|
method: <%- resourceApi.method %>
|
|
25
|
-
authorizer: authorizerIdentifiers
|
|
26
25
|
#<#<%- firstLetterUpperCase(resourceApi.event) _%><%- firstLetterUpperCase(handlerType) %>UserLevelAuthorizer#>
|
|
26
|
+
# authorizer: authorizerIdentifiers
|
|
27
27
|
#<#/<%- firstLetterUpperCase(resourceApi.event) _%><%- firstLetterUpperCase(handlerType) %>UserLevelAuthorizer#>
|
|
28
28
|
<%_ }) _%>
|
|
29
29
|
<%_ } _%>
|
|
@@ -64,7 +64,7 @@ module.exports.createObjectComplete = async (
|
|
|
64
64
|
callingFlowConfig
|
|
65
65
|
});
|
|
66
66
|
|
|
67
|
-
|
|
67
|
+
const errorsFound = [];
|
|
68
68
|
|
|
69
69
|
if (_.isEmpty(returnValue)) {
|
|
70
70
|
_izContext.logger.debug('message callingFlowProperties is empty');
|
|
@@ -72,43 +72,43 @@ module.exports.createObjectComplete = async (
|
|
|
72
72
|
}
|
|
73
73
|
// validate.
|
|
74
74
|
if (!returnValue.hasOwnProperty('queryResult')) {
|
|
75
|
-
|
|
75
|
+
errorsFound.push(
|
|
76
76
|
'message is not have property queryResult, should be not happen'
|
|
77
77
|
);
|
|
78
78
|
}
|
|
79
79
|
if (!returnValue.hasOwnProperty('objType')) {
|
|
80
|
-
|
|
80
|
+
errorsFound.push(
|
|
81
81
|
'message is not have property objType, should be not happen'
|
|
82
82
|
);
|
|
83
83
|
}
|
|
84
84
|
if (!returnValue.hasOwnProperty('objInstance')) {
|
|
85
|
-
|
|
85
|
+
errorsFound.push(
|
|
86
86
|
'message is not have property objInstance, should be not objInstance'
|
|
87
87
|
);
|
|
88
88
|
}
|
|
89
89
|
|
|
90
90
|
if (status == 'error' && errorsFound.length > 0) {
|
|
91
|
-
|
|
91
|
+
errorsFound.push(errorsFound);
|
|
92
92
|
} else if (status == 'error' && errorsFound.length == 0) {
|
|
93
|
-
|
|
94
|
-
'[invalid]
|
|
93
|
+
errorsFound.push(
|
|
94
|
+
'[invalid]status is error not have errorsFound form graphService'
|
|
95
95
|
);
|
|
96
96
|
}
|
|
97
97
|
if (status === 'complete' && errorsFound.length > 0) {
|
|
98
|
-
|
|
99
|
-
'[Invalid] status is
|
|
98
|
+
errorsFound.push(
|
|
99
|
+
'[Invalid] status is complete should be not have errorsFound'
|
|
100
100
|
);
|
|
101
101
|
}
|
|
102
102
|
if (graphServiceTag == '') {
|
|
103
|
-
|
|
103
|
+
errorsFound.push('[Invalid] graphServiceTag is not empty string');
|
|
104
104
|
}
|
|
105
105
|
|
|
106
106
|
if (errorsFound.length > 0) {
|
|
107
|
-
_izContext.logger.debug('Have error form
|
|
108
|
-
|
|
107
|
+
_izContext.logger.debug('Have error form graphService:', errorsFound);
|
|
108
|
+
errorsFound = errorsFound.concat(errorsFound);
|
|
109
109
|
}
|
|
110
110
|
|
|
111
|
-
// check and remove
|
|
111
|
+
// check and remove awaitingStep finish.
|
|
112
112
|
let awaitingStepId = asyncFlowSharedLib.createAwaitingStepId(
|
|
113
113
|
hash({
|
|
114
114
|
objType: returnValue.objType,
|
|
@@ -128,7 +128,7 @@ module.exports.createObjectComplete = async (
|
|
|
128
128
|
);
|
|
129
129
|
_izContext.logger.debug('record awaitingSteps::', recordAwaitingSteps);
|
|
130
130
|
|
|
131
|
-
|
|
131
|
+
nextAwaitingSteps: for (let listRecordAwaitingStep of recordAwaitingSteps.Items) {
|
|
132
132
|
_izContext.logger.debug(
|
|
133
133
|
'iterate RecordAwaitingStep:',
|
|
134
134
|
listRecordAwaitingStep
|
|
@@ -142,8 +142,8 @@ module.exports.createObjectComplete = async (
|
|
|
142
142
|
))
|
|
143
143
|
) {
|
|
144
144
|
_izContext.logger.debug('!Waiting record form other graph::');
|
|
145
|
-
// **** add step of remove
|
|
146
|
-
continue
|
|
145
|
+
// **** add step of remove awaitingMultiples!! ??
|
|
146
|
+
continue nextAwaitingSteps;
|
|
147
147
|
}
|
|
148
148
|
|
|
149
149
|
await asyncFlowSharedLib.removeAwaitingMultipleStep(
|
|
@@ -160,7 +160,7 @@ module.exports.createObjectComplete = async (
|
|
|
160
160
|
let messageObject = {
|
|
161
161
|
objType: returnValue.objType,
|
|
162
162
|
identifierId: returnValue.objInstance.identifiers,
|
|
163
|
-
|
|
163
|
+
errorsFound: errorsFound
|
|
164
164
|
};
|
|
165
165
|
|
|
166
166
|
messageObject =
|