@izara_project/izara-core-generate-service-code 1.0.14 → 1.0.16

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@izara_project/izara-core-generate-service-code",
3
- "version": "1.0.14",
3
+ "version": "1.0.16",
4
4
  "description": "Code for locally generating per service files",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -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
- import { middlewareHandler, validatorSchema, response } from "@izara_project/izara-middleware";
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
- "<%- action %>",
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 (response.failure(lambdaFunctionResponse));
71
+ return response.failure(lambdaFunctionResponse);
58
72
  }
59
73
 
60
74
  // return success to client
61
- return (response.success(lambdaFunctionResponse));
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 (response.failure(err));
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 errorFound:::", errorsFound);
487
+ _izContext.logger.debug("Case have errorsFound:::", errorsFound);
488
488
 
489
489
  // remove awaitingMultipleStep. [[[[[[[open when not test local.]]]]]]]
490
490
  await asyncFlowSharedLib.clearAllAwaitingSteps(
@@ -185,7 +185,7 @@ export default async function getMain(
185
185
 
186
186
  let messageObject = {
187
187
  objType: objType,
188
- objInstanceFull: dataFromGraph.queryResults.refactoredNodes.objInstanceFull
188
+ objInstanceFull: dataFromGraph.returnValue.queryResults.refactoredNodes.objInstanceFull
189
189
  }
190
190
  // send message to SNS ProcessFindRequiredData
191
191
  _izContext.logger.debug("HAVE CallingFlow");
@@ -139,7 +139,7 @@ async function createParamForCreateSource(
139
139
  }
140
140
 
141
141
  let event;
142
- if (handler === HANDLER.hdrApi) {
142
+ if (handler === HANDLER.hdrApi && action !== ACTIONS.get) {
143
143
  event = httpEvent(action);
144
144
  } else if (handler === HANDLER.hdrDsq || handler === HANDLER.hdrSqs) {
145
145
  event = sqsEvent(handler);
@@ -258,7 +258,7 @@ async function createParamForCreateSource(
258
258
  }
259
259
 
260
260
  let resourceApis = [];
261
- if (handler === HANDLER.hdrApi) {
261
+ if (handler === HANDLER.hdrApi && action !== ACTIONS.get) {
262
262
  for (const objectSchema of allObjSchemas.records) {
263
263
  resourceApis.push({
264
264
  event: lowerCase(objectSchema.objectType),
@@ -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
- let errorFounds = [];
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
- errorFounds.push(
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
- errorFounds.push(
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
- errorFounds.push(
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
- errorFounds.push(errorsFound);
91
+ errorsFound.push(errorsFound);
92
92
  } else if (status == 'error' && errorsFound.length == 0) {
93
- errorFounds.push(
94
- '[invalid]statur is error not have errorfound form graphService'
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
- errorFounds.push(
99
- '[Invalid] status is commplete should be not have errorsFound'
98
+ errorsFound.push(
99
+ '[Invalid] status is complete should be not have errorsFound'
100
100
  );
101
101
  }
102
102
  if (graphServiceTag == '') {
103
- errorFounds.push('[Invalid] graphServiceTag is not empty string');
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 grapService:', errorsFound);
108
- errorFounds = errorFounds.concat(errorsFound);
107
+ _izContext.logger.debug('Have error form graphService:', errorsFound);
108
+ errorsFound = errorsFound.concat(errorsFound);
109
109
  }
110
110
 
111
- // check and remove awaitngStep finish.
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
- nextAwaitingAteps: for (let listRecordAwaitingStep of recordAwaitingSteps.Items) {
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 awaitingMultiplestep!! ??
146
- continue nextAwaitingAteps;
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
- errorFounds: errorFounds
163
+ errorsFound: errorsFound
164
164
  };
165
165
 
166
166
  messageObject =