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

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.13",
3
+ "version": "1.0.14",
4
4
  "description": "Code for locally generating per service files",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -43,6 +43,7 @@ await findDataSharedLib.completeFindDataMain(
43
43
  findDataMain.objType,
44
44
  findDataMain.identifiers,
45
45
  dataValue,
46
+ overWriteCache,
46
47
  callingFlow,
47
48
  'complete'
48
49
  );
@@ -72,6 +72,7 @@ await findDataSharedLib.completeFindDataMain(
72
72
  findDataMain.objType,
73
73
  findDataMain.identifiers,
74
74
  dataValue,
75
+ overWriteCache,
75
76
  callingFlow,
76
77
  'complete'
77
78
  );
@@ -30,7 +30,7 @@ middleware.setValidatorSchema(recordHandlerSharedLib.baseValidatorSchema());
30
30
  // set schema for record.body.Message
31
31
  const perRecordsValidatorSchema = {
32
32
  type: 'object',
33
- required: ['fieldName', 'objType', 'identifiers'],
33
+ required: ['fieldName', 'objType', 'identifiers', 'overWriteCache'],
34
34
  properties: {
35
35
  fieldName: {
36
36
  type: 'object'
@@ -49,6 +49,9 @@ const perRecordsValidatorSchema = {
49
49
  identifiers: {
50
50
  type: 'object'
51
51
  },
52
+ overWriteCache: {
53
+ type: 'boolean'
54
+ },
52
55
  callingFlow: {
53
56
  type: 'string',
54
57
  default: ''
@@ -94,6 +97,7 @@ export const main = middleware.wrap(async (event, context) => {
94
97
  passOnProperties.push(record.body.Message.fieldName);
95
98
  passOnProperties.push(record.body.Message.objType);
96
99
  passOnProperties.push(record.body.Message.identifiers);
100
+ passOnProperties.push(record.body.Message.overWriteCache);
97
101
  passOnProperties.push(record.body.Message.callingFlow);
98
102
  record._izContext.logger.debug(
99
103
  'passOnProperties in handler',
@@ -128,4 +132,4 @@ export const main = middleware.wrap(async (event, context) => {
128
132
  Logger.error('Unhandled Error, FindDataHdrSqs: ', err);
129
133
  throw err;
130
134
  }
131
- });
135
+ });
@@ -15,8 +15,6 @@ 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
- 'use strict';
19
-
20
18
  import findDataSharedLib from '@izara_project/izara-core-library-find-data';
21
19
  import graphSharedLib from '@izara_project/izara-core-library-graph-service';
22
20
  import dynamodbSharedLib from '@izara_project/izara-core-library-dynamodb'
@@ -32,6 +30,7 @@ import { serviceConfig, identifiersObject as identifierObj } from '@izara_projec
32
30
  * @param {string} fieldName
33
31
  * @param {Object} objType
34
32
  * @param {Object} identifiers
33
+ * @param {Boolean} overWriteCache
35
34
  *
36
35
  * @returns {object} description of return value
37
36
  */
@@ -41,7 +40,9 @@ export default async function findData(
41
40
  fieldName,
42
41
  objType,
43
42
  identifiers,
43
+ overWriteCache,
44
44
  callingFlow,
45
+
45
46
  //(<additionalParams>)
46
47
  //(</additionalParams>)
47
48
  ) {
@@ -52,6 +53,7 @@ export default async function findData(
52
53
  fieldName: fieldName,
53
54
  objType: objType,
54
55
  identifiers: identifiers,
56
+ overWriteCache: overWriteCache,
55
57
  callingFlow: callingFlow
56
58
  });
57
59
 
@@ -60,6 +62,8 @@ export default async function findData(
60
62
  //(<removeAttributes>)
61
63
  //(</removeAttributes>)
62
64
 
65
+ let deleteDataTableOnExpired = [];
66
+
63
67
  // Check/create FindDataMain status
64
68
  let [findDataMainStatus, findDataId, findDataMain] = await findDataSharedLib.checkFindDataMainStatus(
65
69
  _izContext,
@@ -67,7 +71,8 @@ export default async function findData(
67
71
  objType,
68
72
  identifiers,
69
73
  callingFlow,
70
- removeAttributes
74
+ removeAttributes,
75
+ overWriteCache
71
76
  );
72
77
  _izContext.logger.debug('result after checkFindDataMainStatus is', {
73
78
  findDataMainStatus: findDataMainStatus,
@@ -90,6 +95,7 @@ export default async function findData(
90
95
  objType,
91
96
  identifiers,
92
97
  null,
98
+ overWriteCache,
93
99
  callingFlow,
94
100
  'error'
95
101
  ];
@@ -61,9 +61,12 @@ export default async function <%- functionName %>Main (
61
61
  //(</hookCode>)
62
62
 
63
63
  <% if (typeof afterPlugInHookTag !== 'undefined' && afterPlugInHookTag) { %>
64
- await handlePlugInHookTag(
64
+ await handlerPlugInHookTag(
65
65
  _izContext,
66
- '<%- afterPlugInHookTag %>',
66
+ '<%- plugHookTag %>',
67
+ '<%- flowTag %>',
68
+ '<%- flowStepName %>',
69
+ '<%- flowStepIndex %>',
67
70
  <%- (function(){
68
71
  const s = JSON.stringify(objType, null, 2);
69
72
  if (s === '{}') return '{\n }';
@@ -71,9 +74,9 @@ export default async function <%- functionName %>Main (
71
74
  const t = s.replace(/"([^\"]+)":\s*"([^\"]*)"/g, "$1: '$2'");
72
75
  return t.replace(/\n/g, '\n ');
73
76
  })() %>,
74
- '<%- functionName %>HdrDsq',
75
- requestParams,
76
- callingFlowConfig,
77
+ '<%- queueNameDsq %>',
78
+ plugInIdentifiers,
79
+ plugInAdditionalRequest
77
80
  );
78
81
  <% } %>
79
82
  return '<%- functionName %> completed successfully';
@@ -64,9 +64,12 @@ export default async function <%- functionName %>Main (
64
64
  //(<hookCodePlugin>)
65
65
  //(</hookCodePlugin>)
66
66
 
67
- await handlePlugInHookTag(
67
+ await handlerPlugInHookTag(
68
68
  _izContext,
69
69
  '<%- plugHookTag %>',
70
+ '<%- flowTag %>',
71
+ '<%- flowStepName %>',
72
+ '<%- flowStepIndex %>',
70
73
  <%- (function(){
71
74
  const s = JSON.stringify(objType, null, 2);
72
75
  if (s === '{}') return '{\n }';
@@ -214,6 +214,9 @@ function buildFlowStepResources(_izContext, flowSchema, saveFilePath) {
214
214
  functionName: `${lowerCase(flowStepName)}${firstIndex}`,
215
215
  plugHookTag: flowStepConfig.plugInHooks[0].plugInHookTag,
216
216
  objType: flowStepConfig.plugInHooks[0].objType,
217
+ flowTag: flowTag,
218
+ flowStepName: flowStepName,
219
+ flowStepIndex: firstIndex,
217
220
  queueNameDsq: `${upperCase(flowTag)}${upperCase(flowStepName)}${currentIndex}HdrDsq`
218
221
  },
219
222
  setting: {
@@ -388,8 +391,11 @@ function buildFlowStepResources(_izContext, flowSchema, saveFilePath) {
388
391
  functionName: `${lowerCase(flowStepName)}${currentIndex}`,
389
392
  afterPlugInHookTag: afterPlugInHookTag,
390
393
  plugInHookTag: plugInHookTag,
391
- objType: pluginHook.objType
392
- // queueNameDsq: `${upperCase(flowTag)}${upperCase(flowStepName)}${currentIndex}HdrDsq`
394
+ objType: pluginHook.objType,
395
+ queueNameDsq: `${upperCase(flowTag)}${upperCase(flowStepName)}${currentIndex}HdrDsq`,
396
+ flowTag: flowTag,
397
+ flowStepName: flowStepName,
398
+ flowStepIndex: firstIndex
393
399
  },
394
400
  setting: {
395
401
  savePath: path.join(flowSchemaSourcePath),
@@ -15,42 +15,39 @@ 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 as middleware } from "@izara_project/izara-middleware";
18
+ import { middlewareHandler as middleware } from '@izara_project/izara-middleware';
21
19
  import Logger from '@izara_project/izara-core-library-logger';
22
- import { recordHandlerSharedLib } from "@izara_project/izara-core-library-record-handler";
20
+ import { recordHandlerSharedLib } from '@izara_project/izara-core-library-record-handler';
23
21
  import callingFlowSharedLib from '@izara_project/izara-core-library-calling-flow';
24
22
 
25
23
  import processLogical from './ProcessLogical_Main.js';
26
24
 
27
-
28
25
  // validate event properties in body.Message of sqs event
29
26
  middleware.setValidatorSchema(recordHandlerSharedLib.baseValidatorSchema());
30
27
 
31
28
  // set schema for record.body.Message
32
29
  const perRecordsValidatorSchema = {
33
- type: "object",
34
- required: [
35
- 'objType',
36
- 'element'
37
- ],
30
+ type: 'object',
31
+ required: ['objType', 'element', 'overWriteCache'],
38
32
  properties: {
39
33
  objType: {
40
34
  type: 'object',
41
- required: ["serviceTag", "objectType"],
35
+ required: ['serviceTag', 'objectType'],
42
36
  properties: {
43
37
  serviceTag: {
44
- type: "string",
38
+ type: 'string',
45
39
  enum: [process.env.iz_serviceTag]
46
40
  },
47
41
  objectType: {
48
- type: "string"
42
+ type: 'string'
49
43
  }
50
44
  }
51
45
  },
52
46
  element: {
53
- type: "object"
47
+ type: 'object'
48
+ },
49
+ overWriteCache: {
50
+ type: 'boolean'
54
51
  },
55
52
  callingFlow: {
56
53
  type: 'string',
@@ -74,56 +71,61 @@ const perRecordsValidatorSchema = {
74
71
  // };
75
72
 
76
73
  export const main = middleware.wrap(async (event, context, callback) => {
77
-
78
74
  try {
79
-
80
75
  let recordPromises = [];
81
76
 
82
77
  // loop each record and send to mainFunction
83
- await Promise.all(event.Records.map(async record => { // promise.all for map() function
84
-
85
- let passOnProperties = []
86
- record._izContext.logger.debug('record ReceiveMsgOutHdrSqs', record);
87
-
88
- // validate message (and MessageAttributes)
89
- await recordHandlerSharedLib.validateRecord(
90
- record, // one record will send to mainFunction
91
- "ProcessLogicalHdrSqs", // queue name that need to retry or send to dlq
92
- perRecordsValidatorSchema, // schema for record.Message
93
- // messageAttributeValidatorSchema // ----- for msgAttr default is null -> do not send this parameter if not want to validate msgAtt
94
- );
95
-
96
- // add argument (to invoke lambda) to passOnProperties[]
97
- passOnProperties.push(record.body.Message.objType)
98
- passOnProperties.push(record.body.Message.element)
99
- passOnProperties.push(record.body.Message.callingFlow)
100
- record._izContext.logger.debug('passOnProperties in handler', passOnProperties);
101
-
102
- // call recordHandlerSharedLib.recordHandler with 3 parameters and return promise(resolve)
103
- let recordPromise = recordHandlerSharedLib.recordHandler(
104
- record, // one record will send to mainFunction
105
- processLogical, // mainFunction that need to invoke.
106
- "ProcessLogicalHdrSqs", // queue name that need to retry or send to dlq
107
- passOnProperties, // all parameters that mainFunction needed.
108
- );
109
- record._izContext.logger.debug('after recordPromise in handler');
110
- recordPromises.push(recordPromise); // push promise to recordPromises
111
- }))
78
+ await Promise.all(
79
+ event.Records.map(async record => {
80
+ // promise.all for map() function
81
+
82
+ let passOnProperties = [];
83
+ record._izContext.logger.debug('record ReceiveMsgOutHdrSqs', record);
84
+
85
+ // validate message (and MessageAttributes)
86
+ await recordHandlerSharedLib.validateRecord(
87
+ record, // one record will send to mainFunction
88
+ 'ProcessLogicalHdrSqs', // queue name that need to retry or send to dlq
89
+ perRecordsValidatorSchema // schema for record.Message
90
+ // messageAttributeValidatorSchema // ----- for msgAttr default is null -> do not send this parameter if not want to validate msgAtt
91
+ );
92
+
93
+ // add argument (to invoke lambda) to passOnProperties[]
94
+ passOnProperties.push(record.body.Message.objType);
95
+ passOnProperties.push(record.body.Message.element);
96
+ passOnProperties.push(record.body.Message.overWriteCache);
97
+ passOnProperties.push(record.body.Message.callingFlow);
98
+ record._izContext.logger.debug(
99
+ 'passOnProperties in handler',
100
+ passOnProperties
101
+ );
102
+
103
+ // call recordHandlerSharedLib.recordHandler with 3 parameters and return promise(resolve)
104
+ let recordPromise = recordHandlerSharedLib.recordHandler(
105
+ record, // one record will send to mainFunction
106
+ processLogical, // mainFunction that need to invoke.
107
+ 'ProcessLogicalHdrSqs', // queue name that need to retry or send to dlq
108
+ passOnProperties // all parameters that mainFunction needed.
109
+ );
110
+ record._izContext.logger.debug('after recordPromise in handler');
111
+ recordPromises.push(recordPromise); // push promise to recordPromises
112
+ })
113
+ );
112
114
 
113
115
  Logger.debug('before Promise.all(recordPromises) in handler');
114
116
  try {
115
117
  // --- main await all promises
116
118
  await Promise.all(recordPromises); // await all promises
117
119
 
118
- return event.Records // return all for local testing
119
-
120
+ return event.Records; // return all for local testing
120
121
  } catch {
121
- Logger.debug('Promise.all(recordPromises) in handler threw error (at least one record did no resolve)');
122
+ Logger.debug(
123
+ 'Promise.all(recordPromises) in handler threw error (at least one record did no resolve)'
124
+ );
122
125
  }
123
126
  Logger.debug('after Promise.all(recordPromises) in handler');
124
-
125
127
  } catch (err) {
126
128
  Logger.error('Unhandled Error, ProcessLogicalHdrSqs: ', err);
127
- throw (err);
129
+ throw err;
128
130
  }
129
- });
131
+ });
@@ -46,6 +46,7 @@ import { identifiersObject as identifierObj } from '@izara_project/izara-core-li
46
46
  * @param {Object} [element.sortKeyValues] - value of fieldNames that is sortKey. (optional)
47
47
  * @param {string} [element.comparison] - use for query in queryElements.sortKeyCondition. (optional)
48
48
  * @param {string} [element.conditionalFieldValues] - user after query for filter data before save to logicalData table. (optional)
49
+ * @param {boolean} overWriteCache
49
50
  *
50
51
  * @returns {string} description of return value
51
52
  */
@@ -54,12 +55,14 @@ export default async function processLogical(
54
55
  _izContext,
55
56
  objType,
56
57
  element,
58
+ overWriteCache,
57
59
  callingFlow
58
60
  ) {
59
61
  try {
60
62
  _izContext.logger.debug('----- ProcessLogical event params -----', {
61
63
  objType: objType,
62
64
  element: element,
65
+ overWriteCache: overWriteCache,
63
66
  callingFlow: callingFlow
64
67
  });
65
68
 
@@ -75,7 +78,8 @@ export default async function processLogical(
75
78
  element, // for create logicalResultId
76
79
  objType,
77
80
  callingFlow,
78
- removeAttributes
81
+ removeAttributes,
82
+ overWriteCache
79
83
  );
80
84
  _izContext.logger.debug('After check logicalMainStatus: ', {
81
85
  logicalResultsMainStatus: logicalResultsMainStatus,
@@ -99,6 +103,7 @@ export default async function processLogical(
99
103
  logicalResultId,
100
104
  logicalResultMain.logicalElement,
101
105
  logicalResultMain.objType,
106
+ overWriteCache,
102
107
  callingFlow,
103
108
  'error'
104
109
  ];
@@ -284,6 +289,7 @@ export default async function processLogical(
284
289
  sortKeyFieldName: sortKeyFieldName,
285
290
  dynamoDbIdentifiers: dynamoDbIdentifiers,
286
291
  comparison: comparison,
292
+ overWriteCache: overWriteCache,
287
293
  callingFlow: callingFlow
288
294
  }),
289
295
  TopicArn: await snsSharedLib.snsTopicArnByFlowSchema(
@@ -361,6 +367,7 @@ export default async function processLogical(
361
367
  partitionKeyFieldName: partitionKeyFieldName,
362
368
  sortKeyFieldName: sortKeyFieldName,
363
369
  dynamoDbIdentifiers: dynamoDbIdentifiers,
370
+ overWriteCache: overWriteCache,
364
371
  callingFlow: callingFlow
365
372
  }),
366
373
  TopicArn: await snsSharedLib.snsTopicArnByFlowSchema(
@@ -424,6 +431,7 @@ export default async function processLogical(
424
431
  logicalResultId,
425
432
  element,
426
433
  objType,
434
+ overWriteCache,
427
435
  callingFlow,
428
436
  'complete',
429
437
  []
@@ -48,7 +48,8 @@ const perRecordsValidatorSchema = {
48
48
  'sortKeyFieldName',
49
49
  'dynamoDbIdentifiers',
50
50
  'startKey',
51
- 'overwriteUniqueRequestId'
51
+ 'overwriteUniqueRequestId',
52
+ 'overWriteCache'
52
53
  ],
53
54
  properties: {
54
55
  logicalResultId: {
@@ -76,6 +77,9 @@ const perRecordsValidatorSchema = {
76
77
  overwriteUniqueRequestId: {
77
78
  type: 'string'
78
79
  },
80
+ overWriteCache: {
81
+ type: 'boolean'
82
+ },
79
83
  callingFlow: {
80
84
  type: 'string',
81
85
  default: ''
@@ -85,14 +89,14 @@ const perRecordsValidatorSchema = {
85
89
 
86
90
  // set schema for record.body.MessageAttributes
87
91
  // const messageAttributeValidatorSchema = {
88
- // type: "object",
92
+ // type: 'object',
89
93
  // required: ['msgAtrrParam1', 'msgAtrrParam2'],
90
94
  // properties: {
91
95
  // msgAtrrParam1: {
92
- // type: "string"
96
+ // type: 'string'
93
97
  // },
94
98
  // msgAtrrParam2: {
95
- // type: "object"
99
+ // type: 'object'
96
100
  // }
97
101
  // }
98
102
  // };
@@ -135,6 +139,7 @@ export const main = middleware.wrap(async (event, context, callback) => {
135
139
  passOnProperties.push(record.body.Message.comparison);
136
140
  passOnProperties.push(record.body.Message.startKey);
137
141
  passOnProperties.push(record.body.Message.overwriteUniqueRequestId);
142
+ passOnProperties.push(record.body.Message.overWriteCache);
138
143
  passOnProperties.push(record.body.Message.callingFlow);
139
144
  record._izContext.logger.debug(
140
145
  'passOnProperties in handler',
@@ -33,7 +33,8 @@ const perRecordsValidatorSchema = {
33
33
  'tableName',
34
34
  'partitionKeyFieldName',
35
35
  'sortKeyFieldName',
36
- 'dynamoDbIdentifiers'
36
+ 'dynamoDbIdentifiers',
37
+ 'overWriteCache'
37
38
  ],
38
39
  properties: {
39
40
  logicalResultId: {
@@ -63,6 +64,9 @@ const perRecordsValidatorSchema = {
63
64
  type: 'string',
64
65
  default: ''
65
66
  },
67
+ overWriteCache: {
68
+ type: 'boolean'
69
+ },
66
70
  callingFlow: {
67
71
  type: 'string',
68
72
  default: ''
@@ -72,14 +76,14 @@ const perRecordsValidatorSchema = {
72
76
 
73
77
  // set schema for record.body.MessageAttributes
74
78
  // const messageAttributeValidatorSchema = {
75
- // type: "object",
79
+ // type: 'object',
76
80
  // required: ['msgAtrrParam1', 'msgAtrrParam2'],
77
81
  // properties: {
78
82
  // msgAtrrParam1: {
79
- // type: "string"
83
+ // type: 'string'
80
84
  // },
81
85
  // msgAtrrParam2: {
82
- // type: "object"
86
+ // type: 'object'
83
87
  // }
84
88
  // }
85
89
  // };
@@ -113,6 +117,7 @@ export const main = middleware.wrap(async (event, context, callback) => {
113
117
  passOnProperties.push(record.body.Message.comparison);
114
118
  passOnProperties.push(record.body.Message.startKey);
115
119
  passOnProperties.push(record.body.Message.overwriteUniqueRequestId);
120
+ passOnProperties.push(record.body.Message.overWriteCache);
116
121
  passOnProperties.push(record.body.Message.callingFlow);
117
122
  record._izContext.logger.debug(
118
123
  'passOnProperties in handler',
@@ -38,6 +38,7 @@ const limit = 2;
38
38
  * @param {string} comparison
39
39
  * @param {Object} startKey
40
40
  * @param {string} overwriteUniqueRequestId
41
+ * @param {boolean} overwriteCache
41
42
  * @param {string} callingFlow
42
43
  *
43
44
  * @returns {string} description of return value
@@ -53,6 +54,7 @@ export default async function paginateProcessLogical(
53
54
  comparison, // optional
54
55
  startKey, // optional
55
56
  overwriteUniqueRequestId, // optional
57
+ overWriteCache,
56
58
  callingFlow // optional
57
59
  ) {
58
60
  try {
@@ -65,6 +67,7 @@ export default async function paginateProcessLogical(
65
67
  comparison: comparison,
66
68
  startKey: startKey,
67
69
  overwriteUniqueRequestId: overwriteUniqueRequestId,
70
+ overWriteCache: overWriteCache,
68
71
  callingFlow: callingFlow
69
72
  });
70
73
 
@@ -101,6 +104,7 @@ export default async function paginateProcessLogical(
101
104
  logicalResultId,
102
105
  logicalResultsMain.logicalElement,
103
106
  logicalResultsMain.objType,
107
+ overWriteCache,
104
108
  callingFlow,
105
109
  'error'
106
110
  ];
@@ -247,9 +251,9 @@ export default async function paginateProcessLogical(
247
251
  logicalResultId,
248
252
  logicalResultsMain.logicalElement,
249
253
  logicalResultsMain.objType,
254
+ overWriteCache,
250
255
  callingFlow,
251
- 'complete',
252
- []
256
+ 'complete'
253
257
  );
254
258
  }
255
259