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

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.
Files changed (111) hide show
  1. package/package.json +1 -1
  2. package/src/GenerateCode.js +1 -1
  3. package/src/SourceManager/CreateSource.js +1 -0
  4. package/src/TemplateData/EndpointPerService/mainFunction/create/template.ejs +2 -3
  5. package/src/TemplateData/EndpointPerService/mainFunction/update/template.ejs +8 -2
  6. package/src/TemplateData/findData/GetByStorage/getByDynamo.ejs +10 -7
  7. package/src/TemplateData/findData/GetByStorage/getByGraph.ejs +15 -10
  8. package/src/TemplateData/findData/handler/template.ejs +51 -56
  9. package/src/TemplateData/findData/mainFunction/template.ejs +17 -16
  10. package/src/TemplateData/flowSchema/event/externalTopic/Process/functionYaml/data.js +31 -34
  11. package/src/TemplateData/flowSchema/event/externalTopic/externalTopicComponent.js +10 -2
  12. package/src/TemplateData/flowSchema/event/ownTopic/EndpointComponent/functionYaml/data.js +5 -0
  13. package/src/TemplateData/flowSchema/event/ownTopic/EndpointComponent/functionYaml/template.ejs +4 -11
  14. package/src/TemplateData/flowSchema/event/ownTopic/statusFieldComponent/MainFunction/template.ejs +1 -1
  15. package/src/TemplateData/flowSchema/event/s3/upload/processFile/mainFunction/template.ejs +1 -1
  16. package/src/TemplateData/flowSchema/event/s3/websocket/dynamoDb/ReservedTableData.js +1 -1
  17. package/src/TemplateData/flowSchema/flowStep/afterPluginHook/templateMain.ejs +18 -9
  18. package/src/TemplateData/flowSchema/flowStep/afterPluginHook/templateResource.ejs +43 -11
  19. package/src/TemplateData/flowSchema/flowStep/afterPluginHook/templateYaml.ejs +43 -16
  20. package/src/TemplateData/flowSchema/flowStep/firstFlowStep/templateHandler.ejs +3 -2
  21. package/src/TemplateData/flowSchema/flowStep/firstFlowStep/templateMain.ejs +14 -6
  22. package/src/TemplateData/flowSchema/flowStep/firstFlowStep/templateYaml.ejs +18 -15
  23. package/src/TemplateData/flowSchema/flowStep/flowStep.js +443 -234
  24. package/src/TemplateData/flowSchema/flowStep/noPlugInHook/templateHandler.ejs +95 -0
  25. package/src/TemplateData/flowSchema/flowStep/noPlugInHook/templateMain.ejs +54 -0
  26. package/src/TemplateData/flowSchema/{components/upload/preSignUrl/reservedLimit/sqs/template.ejs → flowStep/noPlugInHook/templateResource.ejs} +17 -18
  27. package/src/TemplateData/flowSchema/flowStep/noPlugInHook/templateYaml.ejs +23 -0
  28. package/src/TemplateData/flowSchema/generateTemplateData.js +6 -9
  29. package/src/TemplateData/flowSchema/{components/upload/relate/libs → libs}/data.js +1 -1
  30. package/src/TemplateData/flowSchema/register/complete/functionYaml/data.js +8 -3
  31. package/src/TemplateData/flowSchema/register/complete/functionYaml/template.ejs +16 -15
  32. package/src/TemplateData/flowSchema/register/wbs/functionYaml/data.js +4 -3
  33. package/src/TemplateData/flowSchema/register/wbs/functionYaml/template.ejs +8 -16
  34. package/src/TemplateData/flowSchema/register/wbs/handler/template.ejs +3 -4
  35. package/src/TemplateData/flowSchema/register/wbs/mainFunction/template.ejs +2 -2
  36. package/src/TemplateData/flowSchema/triggerCacheComponent/checkTriggerCacheComplete/mainFunction/template.ejs +1 -1
  37. package/src/TemplateData/flowSchema/{event/s3/websocket → webSocket}/connect/functionYaml/data.js +7 -4
  38. package/src/TemplateData/flowSchema/webSocket/connect/functionYaml/template.ejs +13 -0
  39. package/src/TemplateData/flowSchema/{components/websocket → webSocket}/connect/handler/data.js +1 -1
  40. package/src/TemplateData/flowSchema/{components/websocket → webSocket}/dynamoDb/WebSocketTaskData.js +2 -2
  41. package/src/TemplateData/flowSchema/{components/websocket → webSocket}/dynamoDb/userUploadRecords.js +1 -1
  42. package/src/TemplateData/flowSchema/webSocketComplete/functionYaml/data.js +7 -2
  43. package/src/TemplateData/flowSchema/webSocketComplete/functionYaml/template.ejs +18 -13
  44. package/src/TemplateData/flowSchema/webSocketComplete/webSocketCompleteComponent.js +8 -1
  45. package/src/TemplateData/generateRole/createSharedResource.js +7 -8
  46. package/src/TemplateData/processLogical/mainFunction/template.ejs +212 -90
  47. package/src/TemplateData/processLogicalPagination/handler/dsq/template.ejs +78 -66
  48. package/src/TemplateData/processLogicalPagination/handler/sqs/template.ejs +65 -58
  49. package/src/TemplateData/processLogicalPagination/mainFunction/template.ejs +107 -55
  50. package/src/TemplateData/flowSchema/components/upload/confirmReserved/functionYaml/data.js +0 -131
  51. package/src/TemplateData/flowSchema/components/upload/confirmReserved/functionYaml/template.ejs +0 -17
  52. package/src/TemplateData/flowSchema/components/upload/confirmReserved/handler/data.js +0 -66
  53. package/src/TemplateData/flowSchema/components/upload/confirmReserved/handler/template.ejs +0 -123
  54. package/src/TemplateData/flowSchema/components/upload/confirmReserved/mainFunction/data.js +0 -58
  55. package/src/TemplateData/flowSchema/components/upload/confirmReserved/mainFunction/template.ejs +0 -129
  56. package/src/TemplateData/flowSchema/components/upload/confirmReserved/queue/data.js +0 -63
  57. package/src/TemplateData/flowSchema/components/upload/confirmReserved/queue/template.ejs +0 -45
  58. package/src/TemplateData/flowSchema/components/upload/createObject/functionYaml/data.js +0 -120
  59. package/src/TemplateData/flowSchema/components/upload/createObject/functionYaml/template.ejs +0 -20
  60. package/src/TemplateData/flowSchema/components/upload/createObject/handler/data.js +0 -67
  61. package/src/TemplateData/flowSchema/components/upload/createObject/handler/template.ejs +0 -83
  62. package/src/TemplateData/flowSchema/components/upload/createObject/mainFunction/data.js +0 -68
  63. package/src/TemplateData/flowSchema/components/upload/createObject/mainFunction/template.ejs +0 -131
  64. package/src/TemplateData/flowSchema/components/upload/createObjectComplete/functionYaml/data.js +0 -120
  65. package/src/TemplateData/flowSchema/components/upload/createObjectComplete/functionYaml/template.ejs +0 -17
  66. package/src/TemplateData/flowSchema/components/upload/createObjectComplete/handler/data.js +0 -65
  67. package/src/TemplateData/flowSchema/components/upload/createObjectComplete/handler/template.ejs +0 -99
  68. package/src/TemplateData/flowSchema/components/upload/createObjectComplete/mainFunction/data.js +0 -63
  69. package/src/TemplateData/flowSchema/components/upload/createObjectComplete/mainFunction/template.ejs +0 -81
  70. package/src/TemplateData/flowSchema/components/upload/createObjectComplete/sns-sqs/data.js +0 -69
  71. package/src/TemplateData/flowSchema/components/upload/createObjectComplete/sns-sqs/template.ejs +0 -49
  72. package/src/TemplateData/flowSchema/components/upload/preSignUrl/createPresignUrl/functionYaml/data.js +0 -142
  73. package/src/TemplateData/flowSchema/components/upload/preSignUrl/createPresignUrl/functionYaml/template.ejs +0 -18
  74. package/src/TemplateData/flowSchema/components/upload/preSignUrl/createPresignUrl/handler/data.js +0 -66
  75. package/src/TemplateData/flowSchema/components/upload/preSignUrl/createPresignUrl/handler/template.ejs +0 -123
  76. package/src/TemplateData/flowSchema/components/upload/preSignUrl/createPresignUrl/mainFunction/data.js +0 -66
  77. package/src/TemplateData/flowSchema/components/upload/preSignUrl/createPresignUrl/mainFunction/template.ejs +0 -262
  78. package/src/TemplateData/flowSchema/components/upload/preSignUrl/createPresignUrl/queue/data.js +0 -64
  79. package/src/TemplateData/flowSchema/components/upload/preSignUrl/createPresignUrl/queue/template.ejs +0 -45
  80. package/src/TemplateData/flowSchema/components/upload/preSignUrl/reservedLimit/functionYaml/data.js +0 -150
  81. package/src/TemplateData/flowSchema/components/upload/preSignUrl/reservedLimit/functionYaml/template.ejs +0 -14
  82. package/src/TemplateData/flowSchema/components/upload/preSignUrl/reservedLimit/handler/data.js +0 -66
  83. package/src/TemplateData/flowSchema/components/upload/preSignUrl/reservedLimit/handler/template.ejs +0 -121
  84. package/src/TemplateData/flowSchema/components/upload/preSignUrl/reservedLimit/mainFunction/data.js +0 -62
  85. package/src/TemplateData/flowSchema/components/upload/preSignUrl/reservedLimit/mainFunction/template.ejs +0 -172
  86. package/src/TemplateData/flowSchema/components/upload/preSignUrl/reservedLimit/sqs/data.js +0 -66
  87. package/src/TemplateData/flowSchema/components/upload/processFile/functionYml/HdrS3/data.js +0 -144
  88. package/src/TemplateData/flowSchema/components/upload/processFile/functionYml/HdrS3/template.ejs +0 -25
  89. package/src/TemplateData/flowSchema/components/upload/processFile/handler/handlerS3/data.js +0 -53
  90. package/src/TemplateData/flowSchema/components/upload/processFile/handler/handlerS3/template.ejs +0 -50
  91. package/src/TemplateData/flowSchema/components/upload/processFile/mainFunction/ProcessCsvtemplate.ejs +0 -182
  92. package/src/TemplateData/flowSchema/components/upload/processFile/mainFunction/data.js +0 -52
  93. package/src/TemplateData/flowSchema/components/upload/processFile/mainFunction/template.ejs +0 -66
  94. package/src/TemplateData/flowSchema/components/upload/processFile/queue/data.js +0 -77
  95. package/src/TemplateData/flowSchema/components/upload/processFile/queue/dsqTemplatePath.ejs +0 -32
  96. package/src/TemplateData/flowSchema/components/upload/processFile/queue/s3Template.ejs +0 -59
  97. package/src/TemplateData/flowSchema/components/upload/relate/S3/data.js +0 -60
  98. package/src/TemplateData/flowSchema/components/upload/relate/S3/template.ejs +0 -13
  99. package/src/TemplateData/flowSchema/components/upload/relate/sns-out/data.js +0 -67
  100. package/src/TemplateData/flowSchema/components/websocket/connect/functionYaml/data.js +0 -96
  101. package/src/TemplateData/flowSchema/components/websocket/connect/functionYaml/template.ejs +0 -17
  102. package/src/TemplateData/flowSchema/components/websocket/dynamoDb/ReservedTableData.js +0 -68
  103. package/src/TemplateData/flowSchema/event/s3/websocket/connect/functionYaml/template.ejs +0 -17
  104. package/src/TemplateData/flowSchema/event/s3/websocket/connect/handler/data.js +0 -58
  105. package/src/TemplateData/flowSchema/event/s3/websocket/connect/handler/template.ejs +0 -72
  106. package/src/TemplateData/flowSchema/event/s3/websocket/dynamoDb/WebSocketTaskData.js +0 -69
  107. package/src/TemplateData/flowSchema/event/s3/websocket/dynamoDb/ttlDynamoTemplate.ejs +0 -32
  108. package/src/TemplateData/flowSchema/event/s3/websocket/dynamoDb/userUploadRecords.js +0 -61
  109. /package/src/TemplateData/flowSchema/{components/upload/relate/libs → libs}/template.ejs +0 -0
  110. /package/src/TemplateData/flowSchema/{components/websocket → webSocket}/connect/handler/template.ejs +0 -0
  111. /package/src/TemplateData/flowSchema/{components/websocket → webSocket}/dynamoDb/ttlDynamoTemplate.ejs +0 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@izara_project/izara-core-generate-service-code",
3
- "version": "1.0.11",
3
+ "version": "1.0.13",
4
4
  "description": "Code for locally generating per service files",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -128,7 +128,7 @@ async function generateCodeWithTemplate(
128
128
  setting.checkCreateSourcePass = true;
129
129
  // console.log({ templatePath })
130
130
  // console.log({ templateData })
131
- let [status, errors] = await createSource(
131
+ const [status, errors] = await createSource(
132
132
  readFileSync(templatePath, 'utf8'),
133
133
  templateData,
134
134
  setting
@@ -111,6 +111,7 @@ async function createSource(
111
111
  generateDataFromTemplate(template, data);
112
112
  return [true, {}];
113
113
  } catch (errors) {
114
+ console.error('Error in createSource checkCreateSourcePass:', errors);
114
115
  return [false, errors];
115
116
  }
116
117
  }
@@ -165,7 +165,6 @@ export default async function createMain(
165
165
 
166
166
  let allAwaitingStepsId = [];
167
167
 
168
- let requestParams;
169
168
  let errors;
170
169
 
171
170
  let identifiers = objectSchemas.identifiers;
@@ -174,10 +173,10 @@ export default async function createMain(
174
173
  //(</createOptionalOnCreateIdentifiers>)
175
174
  if (identifiers.length === 1 && !identifiers[0].hasOwnProperty("fieldNames")) {
176
175
  let identifier = identifiers[0];
177
- [requestParams, errors] = await createIdentifiersByUseCase(requestParams, objectSchemas, identifier, optionalOnCreateIdentifiers)
176
+ [requestParams, errors] = await createIdentifiersByUseCase(_izContext, requestParams, objectSchemas, identifier, optionalOnCreateIdentifiers)
178
177
  } else if (identifiers.length > 1) {
179
178
  for (const identifier of identifiers) {
180
- [requestParams, errors] = await createIdentifiersByUseCase(requestParams, objectSchemas, identifier, optionalOnCreateIdentifiers)
179
+ [requestParams, errors] = await createIdentifiersByUseCase(_izContext, requestParams, objectSchemas, identifier, optionalOnCreateIdentifiers)
181
180
  }
182
181
  }
183
182
  _izContext.logger.debug("requestParams is:", requestParams);
@@ -21,7 +21,7 @@ import { objectHash as hash } from '@izara_project/izara-shared-core';
21
21
  import { consts as coreConsts, NoRetryError } from '@izara_project/izara-core-library-core';
22
22
 
23
23
  // ==================== Core Service Schemas ====================
24
- import { getObjectSchema, consts, utils, identifiersObject, dataDetailsLib } from '@izara_project/izara-core-library-service-schemas';
24
+ import { getObjectSchema, consts, utils, identifiersObject, dataDetailsLib, uploadUseCase } from '@izara_project/izara-core-library-service-schemas';
25
25
  const { createObjType } = utils;
26
26
  const { dynamoDbIdentifiersByStorageResource } = identifiersObject;
27
27
  const { createUpdateDataDetail } = dataDetailsLib;
@@ -102,6 +102,12 @@ export default async function updateMain(
102
102
  );
103
103
  _izContext.logger.debug("objectSchema", objectSchema);
104
104
 
105
+ let objectSchemas = await uploadUseCase.generateObjectSchemaForCombineFieldNames(
106
+ _izContext,
107
+ objectSchema
108
+ );
109
+ _izContext.logger.debug("objectSchemas", objectSchemas);
110
+
105
111
  let userId;
106
112
  let targetId;
107
113
  if (objectSchema.generatedBy === "userGenerated") {
@@ -134,7 +140,7 @@ export default async function updateMain(
134
140
 
135
141
  let updateDataDetails = await createUpdateDataDetail(
136
142
  _izContext,
137
- objectSchema,
143
+ objectSchemas,
138
144
  );
139
145
 
140
146
  _izContext.logger.debug("updateDataDetails", updateDataDetails);
@@ -3,7 +3,7 @@ let identifiersBase = await identifierObj.identifiersBaseFromIdentifiers(
3
3
  objType,
4
4
  identifiers,
5
5
  );
6
- _izContext.logger.debug("create identifiersBase from identifiers: ", identifiersBase) // object
6
+ _izContext.logger.debug('create identifiersBase from identifiers: ', identifiersBase) // object
7
7
 
8
8
  <%- createNameTagBefore(objectType, fieldName) %>
9
9
 
@@ -12,36 +12,39 @@ let objInstanceBase = await dynamodbSharedLib.getItem(
12
12
  await dynamodbSharedLib.tableName(_izContext, <%- JSON.stringify(tableName) %>),
13
13
  identifiersBase
14
14
  );
15
- _izContext.logger.debug("objInstanceBase: ", objInstanceBase)
15
+ _izContext.logger.debug('objInstanceBase: ', objInstanceBase)
16
16
 
17
17
  if (!objInstanceBase) {
18
18
  errorsFound.push(`can't get data in dynamo by ${identifiersBase}`)
19
19
  standardErrorParams.push(errorsFound)
20
20
  await findDataSharedLib.completeFindDataMain(...standardErrorParams);
21
- return;
21
+ return {
22
+ returnResponse: 'FindData cannot get data in dynamo'
23
+ }
22
24
  }
23
25
 
24
26
  if (!objInstanceBase.hasOwnProperty(fieldName.fieldName)) {
25
27
  errorsFound.push(`data in dynamoDB have no ${fieldName.fieldName}`)
26
28
  standardErrorParams.push(errorsFound)
27
29
  await findDataSharedLib.completeFindDataMain(...standardErrorParams);
28
- return;
30
+ return {
31
+ returnResponse: 'Data have no fieldName'
32
+ }
29
33
  }
30
34
 
31
35
  <%- createNameTagAfter(objectType, fieldName) %>
32
36
 
33
37
  let dataValue = objInstanceBase[fieldName.fieldName];
34
- _izContext.logger.debug("dataValue: ", dataValue)
38
+ _izContext.logger.debug('dataValue: ', dataValue)
35
39
 
36
40
  await findDataSharedLib.completeFindDataMain(
37
41
  _izContext,
38
42
  findDataMain.fieldName,
39
43
  findDataMain.objType,
40
44
  findDataMain.identifiers,
41
- findDataMain.requestProperties,
42
45
  dataValue,
43
46
  callingFlow,
44
- "complete"
47
+ 'complete'
45
48
  );
46
49
 
47
50
  <%_ function createNameTagBefore(objectType, fieldName){
@@ -4,7 +4,7 @@ const graphHandlerServiceTag = await serviceConfig.getGraphServiceTagWithCache(
4
4
  _izContext,
5
5
  <%- JSON.stringify(graphServerTag) %>,
6
6
  );
7
- _izContext.logger.debug("graphHandlerServiceTag: ", graphHandlerServiceTag)
7
+ _izContext.logger.debug('graphHandlerServiceTag: ', graphHandlerServiceTag)
8
8
 
9
9
  let getDataByGraph = await graphSharedLib.getNodeV2(
10
10
  _izContext,
@@ -16,20 +16,22 @@ let getDataByGraph = await graphSharedLib.getNodeV2(
16
16
  <%- JSON.stringify(versionedDataLabel) %>
17
17
  );
18
18
 
19
- _izContext.logger.debug("getDataByGraph: ", getDataByGraph)
19
+ _izContext.logger.debug('getDataByGraph: ', getDataByGraph)
20
20
 
21
21
 
22
22
  if (!getDataByGraph) {
23
23
  errorsFound.push(`can't get data of ${objType.objectType} in graph`)
24
24
  standardErrorParams.push(errorsFound)
25
25
  await findDataSharedLib.completeFindDataMain(...standardErrorParams);
26
- return;
26
+ return {
27
+ returnResponse: 'FindData cannot get data in graph'
28
+ }
27
29
  }
28
30
 
29
31
  <%- createNameTagAfter(objectType, fieldName) %>
30
32
 
31
33
  let objInstanceFull = getDataByGraph.returnValue.queryResults.refactoredNodes.objInstanceFull;
32
- _izContext.logger.debug("objInstanceFull: ", objInstanceFull)
34
+ _izContext.logger.debug('objInstanceFull: ', objInstanceFull)
33
35
 
34
36
 
35
37
  <% if (getInIdentifiers) { _%>
@@ -39,11 +41,13 @@ if (!getDataByGraph) {
39
41
  errorsFound.push(`nodeProperties have no this ${fieldName.fieldName}`)
40
42
  standardErrorParams.push(errorsFound)
41
43
  await findDataSharedLib.completeFindDataMain(...standardErrorParams);
42
- return;
44
+ return {
45
+ returnResponse: 'Data have no fieldName'
46
+ }
43
47
  }
44
48
 
45
49
  let dataValue = objInstanceFull.identifiers[fieldName.fieldName];
46
- _izContext.logger.debug("this fieldName is identifier, get dataValue in identifiers: ", dataValue)
50
+ _izContext.logger.debug('this fieldName is identifier, get dataValue in identifiers: ', dataValue)
47
51
 
48
52
  <% } else { _%>
49
53
 
@@ -52,11 +56,13 @@ if (!getDataByGraph) {
52
56
  errorsFound.push(`nodeProperties have no this ${fieldName.fieldName}`)
53
57
  standardErrorParams.push(errorsFound)
54
58
  await findDataSharedLib.completeFindDataMain(...standardErrorParams);
55
- return;
59
+ return {
60
+ returnResponse: 'Data have no fieldName'
61
+ }
56
62
  }
57
63
 
58
64
  let dataValue = objInstanceFull.fields[fieldName.fieldName];
59
- _izContext.logger.debug("this fieldName is not identifier, get dataValue in fields: ", dataValue)
65
+ _izContext.logger.debug('this fieldName is not identifier, get dataValue in fields: ', dataValue)
60
66
 
61
67
  <% }_%>
62
68
 
@@ -65,10 +71,9 @@ await findDataSharedLib.completeFindDataMain(
65
71
  findDataMain.fieldName,
66
72
  findDataMain.objType,
67
73
  findDataMain.identifiers,
68
- findDataMain.requestProperties,
69
74
  dataValue,
70
75
  callingFlow,
71
- "complete"
76
+ 'complete'
72
77
  );
73
78
 
74
79
  <%_ function createNameTagBefore(objectType, fieldName){
@@ -15,10 +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 as middleware, validatorSchema } from "@izara_project/izara-middleware";
21
- import { recordHandlerSharedLib } from "@izara_project/izara-core-library-record-handler";
18
+ import {
19
+ middlewareHandler as middleware,
20
+ validatorSchema
21
+ } from '@izara_project/izara-middleware';
22
+ import { recordHandlerSharedLib } from '@izara_project/izara-core-library-record-handler';
22
23
  import Logger from '@izara_project/izara-core-library-logger';
23
24
 
24
25
  import findData from './FindData_Main.js';
@@ -28,22 +29,18 @@ middleware.setValidatorSchema(recordHandlerSharedLib.baseValidatorSchema());
28
29
 
29
30
  // set schema for record.body.Message
30
31
  const perRecordsValidatorSchema = {
31
- type: "object",
32
- required: [
33
- 'fieldName',
34
- 'objType',
35
- 'identifiers',
36
- ],
32
+ type: 'object',
33
+ required: ['fieldName', 'objType', 'identifiers'],
37
34
  properties: {
38
35
  fieldName: {
39
- type: 'object',
36
+ type: 'object'
40
37
  },
41
38
  objType: {
42
39
  type: 'object',
43
- required: ["serviceTag", "objectType"],
40
+ required: ['serviceTag', 'objectType'],
44
41
  properties: {
45
42
  serviceTag: {
46
- type: "string",
43
+ type: 'string',
47
44
  enum: [process.env.iz_serviceTag]
48
45
  },
49
46
  objectType: validatorSchema.stringNotEmpty()
@@ -52,15 +49,10 @@ const perRecordsValidatorSchema = {
52
49
  identifiers: {
53
50
  type: 'object'
54
51
  },
55
- requestProperties: {
56
- type: 'object',
57
- default: {}
58
- },
59
52
  callingFlow: {
60
53
  type: 'string',
61
54
  default: ''
62
55
  }
63
-
64
56
  }
65
57
  };
66
58
 
@@ -79,58 +71,61 @@ const perRecordsValidatorSchema = {
79
71
  // };
80
72
 
81
73
  export const main = middleware.wrap(async (event, context) => {
82
-
83
74
  try {
84
-
85
75
  let recordPromises = [];
86
76
 
87
77
  // loop each record and send to mainFunction
88
- await Promise.all(event.Records.map(async record => { // promise.all for map() function
89
-
90
- let passOnProperties = [];
91
- record._izContext.logger.debug('record ReceiveMsgOutHdrSqs', record);
92
-
93
- // validate message (and MessageAttributes)
94
- await recordHandlerSharedLib.validateRecord(
95
- record, // one record will send to mainFunction
96
- "FindDataHdrSqs", // queue name that need to retry or send to dlq
97
- perRecordsValidatorSchema, // schema for record.Message
98
- // messageAttributeValidatorSchema // ----- for msgAttr default is null -> do not send this parameter if not want to validate msgAtt
99
- );
100
-
101
- // add argument (to invoke lambda) to passOnProperties[]
102
- passOnProperties.push(record.body.Message.fieldName)
103
- passOnProperties.push(record.body.Message.objType)
104
- passOnProperties.push(record.body.Message.identifiers)
105
- passOnProperties.push(record.body.Message.requestProperties)
106
- passOnProperties.push(record.body.Message.callingFlow)
107
- record._izContext.logger.debug('passOnProperties in handler', passOnProperties);
108
-
109
- // call recordHandlerSharedLib.recordHandler with 3 parameters and return promise(resolve)
110
- let recordPromise = recordHandlerSharedLib.recordHandler(
111
- record, // one record will send to mainFunction
112
- findData, // mainFunction that need to invoke.
113
- "FindDataHdrSqs", // queue name that need to retry or send to dlq
114
- passOnProperties, // all parameters that mainFunction needed.
115
- );
116
- record._izContext.logger.debug('after recordPromise in handler');
117
- recordPromises.push(recordPromise); // push promise to recordPromises
118
- }))
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
+ 'FindDataHdrSqs', // 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.fieldName);
95
+ passOnProperties.push(record.body.Message.objType);
96
+ passOnProperties.push(record.body.Message.identifiers);
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
+ findData, // mainFunction that need to invoke.
107
+ 'FindDataHdrSqs', // 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
+ );
119
114
 
120
115
  Logger.debug('before Promise.all(recordPromises) in handler');
121
116
  try {
122
117
  // --- main await all promises
123
118
  await Promise.all(recordPromises); // await all promises
124
119
 
125
- return event.Records // return all for local testing
126
-
120
+ return event.Records; // return all for local testing
127
121
  } catch {
128
- 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
+ );
129
125
  }
130
126
  Logger.debug('after Promise.all(recordPromises) in handler');
131
-
132
127
  } catch (err) {
133
128
  Logger.error('Unhandled Error, FindDataHdrSqs: ', err);
134
- throw (err);
129
+ throw err;
135
130
  }
136
131
  });
@@ -32,7 +32,6 @@ import { serviceConfig, identifiersObject as identifierObj } from '@izara_projec
32
32
  * @param {string} fieldName
33
33
  * @param {Object} objType
34
34
  * @param {Object} identifiers
35
- * @param {Object} requestProperties
36
35
  *
37
36
  * @returns {object} description of return value
38
37
  */
@@ -42,7 +41,6 @@ export default async function findData(
42
41
  fieldName,
43
42
  objType,
44
43
  identifiers,
45
- requestProperties,
46
44
  callingFlow,
47
45
  //(<additionalParams>)
48
46
  //(</additionalParams>)
@@ -54,7 +52,6 @@ export default async function findData(
54
52
  fieldName: fieldName,
55
53
  objType: objType,
56
54
  identifiers: identifiers,
57
- requestProperties: requestProperties,
58
55
  callingFlow: callingFlow
59
56
  });
60
57
 
@@ -69,19 +66,20 @@ export default async function findData(
69
66
  fieldName,
70
67
  objType,
71
68
  identifiers,
72
- requestProperties,
73
69
  callingFlow,
74
70
  removeAttributes
75
71
  );
76
- _izContext.logger.debug("result after checkFindDataMainStatus is", {
72
+ _izContext.logger.debug('result after checkFindDataMainStatus is', {
77
73
  findDataMainStatus: findDataMainStatus,
78
74
  findDataId: findDataId,
79
75
  findDataMain: findDataMain
80
76
  })
81
77
 
82
- if (findDataMainStatus != "process") {
78
+ if (findDataMainStatus != 'process') {
83
79
  _izContext.logger.debug(`findDataMainStatus status isn't process :${findDataMainStatus}`)
84
- return; // stop process
80
+ return {
81
+ returnResponse: 'Function FindData not process'
82
+ }
85
83
  };
86
84
 
87
85
  let errorsFound = [];
@@ -91,27 +89,26 @@ export default async function findData(
91
89
  fieldName,
92
90
  objType,
93
91
  identifiers,
94
- requestProperties,
95
92
  null,
96
93
  callingFlow,
97
- "error"
94
+ 'error'
98
95
  ];
99
96
 
100
97
  <% for (let idx = 0; idx < datas.length; idx++) { _%>
101
98
  <% let objectType = datas[idx].objectType _%>
102
99
  if (objType.objectType === <%- JSON.stringify(objectType) %>) {
103
- _izContext.logger.debug("objectType: ", objType.objectType)
100
+ _izContext.logger.debug('objectType: ', objType.objectType)
104
101
 
105
102
  <% let fieldNames = datas[idx].fieldNames _%>
106
103
  <% for (let idx = 0; idx < fieldNames.length; idx++) { _%>
107
104
  <% let fieldName = Object.keys(fieldNames[idx])[0] _%>
108
105
  <% let storageDetails = (Object.values(fieldNames[idx])[0]) _%>
109
106
  if (fieldName.fieldName == <%- JSON.stringify(fieldName) %>) {
110
- _izContext.logger.debug("fieldName: ", fieldName.fieldName)
107
+ _izContext.logger.debug('fieldName: ', fieldName.fieldName)
111
108
 
112
109
  <% Object.entries(storageDetails).map(([storage, details]) => { _%>
113
110
  <% let versionedDataLabel = [] _%>
114
- <% if (storage === storageTypeGraph && details.hasOwnProperty("versionedDataLabel")){ versionedDataLabel.push(details.versionedDataLabel) } _%>
111
+ <% if (storage === storageTypeGraph && details.hasOwnProperty('versionedDataLabel')){ versionedDataLabel.push(details.versionedDataLabel) } _%>
115
112
  <% if (storage === storageDynamo){ %><%- include(getByDynamoTemplate, {tableName: details.tableName, fieldName: fieldName, objectType: objectType}) %><% } _%>
116
113
  <% if (storage === storageTypeGraph){ %><%- include(getByGraphTemplate, {graphServerTag: details.graphServerTag, versionedDataLabel: versionedDataLabel, fieldName: fieldName, objectType: objectType, getInIdentifiers: details.getInIdentifiers}) %><% } _%>
117
114
  <% }) _%>
@@ -119,7 +116,7 @@ export default async function findData(
119
116
  <%- createAdditionalFieldNamesTag(objectType) %>
120
117
  <% } _%>
121
118
  else <% } _%> {
122
- errorsFound.push("unrecognized fieldName")
119
+ errorsFound.push('unrecognized fieldName')
123
120
  standardErrorParams.push(errorsFound)
124
121
  await findDataSharedLib.completeFindDataMain(...standardErrorParams);
125
122
  return;
@@ -129,13 +126,17 @@ export default async function findData(
129
126
  //(</additionalObjectType>)
130
127
  <% } _%>
131
128
  else<% } %> {
132
- errorsFound.push("unrecognized objectType")
129
+ errorsFound.push('unrecognized objectType')
133
130
  standardErrorParams.push(errorsFound)
134
131
  await findDataSharedLib.completeFindDataMain(...standardErrorParams);
135
- return;
132
+ return {
133
+ returnResponse: 'Function FindData Error'
134
+ }
136
135
  }
137
136
 
138
- return "Function FindData Finish";
137
+ return {
138
+ returnResponse: 'Function FindData Finish'
139
+ }
139
140
 
140
141
  } catch (err) {
141
142
  _izContext.logger.error('error FindDataMain: ', err)
@@ -50,17 +50,12 @@ const {
50
50
  const templatePath = path.join(__dirname, 'template.ejs');
51
51
 
52
52
  /**
53
- * receive objectSchema
54
- * create data for WebScoket handler template
55
- *
56
- * @param {Object} objectSchema
57
- * @return {{templatePath, templateData,setting}}
53
+ * Creates source parameters for function YAML generation
54
+ * @param {Object} _izContext - The Izara context object
55
+ * @param {Object} flowSchema - The flow schema configuration
56
+ * @param {string} srcPath - The source path for the project
57
+ * @returns {Promise<Array>} Array containing template configuration object
58
58
  */
59
-
60
- function data(_izContext, flowSchema, srcPath) {
61
- return [createSourceParams(_izContext, flowSchema, srcPath)];
62
- }
63
-
64
59
  async function createSourceParams(_izContext, flowSchema, srcPath) {
65
60
  let functionName = 'Process' + upperCase(flowSchema.flowTag);
66
61
  let handlerType = upperCase(HANDLER.hdrSqs);
@@ -134,30 +129,32 @@ async function createSourceParams(_izContext, flowSchema, srcPath) {
134
129
  );
135
130
  }
136
131
 
137
- return {
138
- templatePath: templatePath,
139
- templateData: {
140
- resourceLocation: path.join(
141
- SOURCE_PATH.resourceLocationFlowSchema,
142
- upperCase(flowSchema.flowTag),
143
- 'source/'
144
- ),
145
- functionName,
146
- handlerType,
147
- additionalResourcePermission,
148
- route,
149
- functionNameConfig:
150
- upperCase(functionName) + upperCase(shortNameHandler(handlerType)),
151
- roleName: upperCase(flowSchema.flowTag),
152
- queueName
153
- },
154
- setting: {
155
- savePath: path.join(srcPath, SOURCE_PATH.appYaml),
156
- saveFileName: upperCase(SAVE_FILE_NAME.flowSchema),
157
- fileExtension: '.yml',
158
- isAppend: true
132
+ return [
133
+ {
134
+ templatePath: templatePath,
135
+ templateData: {
136
+ resourceLocation: path.join(
137
+ SOURCE_PATH.resourceLocationFlowSchema,
138
+ upperCase(flowSchema.flowTag),
139
+ 'source/'
140
+ ),
141
+ functionName,
142
+ handlerType,
143
+ additionalResourcePermission,
144
+ route,
145
+ functionNameConfig:
146
+ upperCase(functionName) + upperCase(shortNameHandler(handlerType)),
147
+ roleName: upperCase(flowSchema.flowTag),
148
+ queueName
149
+ },
150
+ setting: {
151
+ savePath: path.join(srcPath, SOURCE_PATH.appYaml),
152
+ saveFileName: upperCase(SAVE_FILE_NAME.flowSchema),
153
+ fileExtension: '.yml',
154
+ isAppend: true
155
+ }
159
156
  }
160
- };
157
+ ];
161
158
  }
162
159
 
163
- export default data;
160
+ export default createSourceParams;
@@ -3,9 +3,17 @@ import createExternalSqsHandler from './Process/handler/data.js';
3
3
  import createExternalTopicSnsInSqs from './sns-in-sqs/data.js';
4
4
  import createExternalTopicSnsOut from './sns-out/data.js';
5
5
 
6
- function createExternalTopicComponent(_izContext, flowSchema, saveFilePath) {
6
+ async function createExternalTopicComponent(
7
+ _izContext,
8
+ flowSchema,
9
+ saveFilePath
10
+ ) {
7
11
  const component = [
8
- ...createExternalSqsFunctionYaml(_izContext, flowSchema, saveFilePath),
12
+ ...(await createExternalSqsFunctionYaml(
13
+ _izContext,
14
+ flowSchema,
15
+ saveFilePath
16
+ )),
9
17
  ...createExternalSqsHandler(_izContext, flowSchema, saveFilePath),
10
18
  ...createExternalTopicSnsInSqs(_izContext, flowSchema, saveFilePath),
11
19
  ...createExternalTopicSnsOut(_izContext, flowSchema, saveFilePath)
@@ -79,6 +79,11 @@ async function createSourceParams(_izContext, flowSchema, srcPath) {
79
79
  upperCase(flowSchema.flowTag),
80
80
  'source/'
81
81
  ),
82
+ handlerFilePath: path.join(
83
+ SOURCE_PATH.resourceLocationFlowSchema,
84
+ upperCase(flowSchema.flowTag),
85
+ 'source/'
86
+ ),
82
87
  functionName,
83
88
  additionalResourcePermission,
84
89
  roleName: upperCase(flowSchema.flowTag)
@@ -1,17 +1,10 @@
1
- <%_ const join = require('path').join; _%>
2
- <%- firstLetterUpperCase(functionNameConfig) %>:
3
- handler: <%- join(resourceLocation, `${firstLetterUpperCase(functionName)}_${firstLetterUpperCase(handlerType)}.main`)%>
4
- name: ${self:custom.iz_resourcePrefix}<%- firstLetterUpperCase(functionName) %><%- firstLetterUpperCase(handlerType) %>
1
+ <%- functionNameConfig %>:
2
+ handler: <%- `${handlerFilePath}${functionName}_${handlerType}.main` %>
3
+ name: ${self:custom.iz_resourcePrefix}<%- functionName %><%- handlerType %>
5
4
  role: <%- roleName %>Role
6
5
  #<#<%- functionName %><%- handlerType %>FunctionSetting#>
7
6
  #<#/<%- functionName %><%- handlerType %>FunctionSetting#>
8
7
  events:
9
8
  - sqs:
10
9
  arn: arn:aws:sqs:${self:custom.iz_region}:${self:custom.iz_accountId}:${self:custom.iz_resourcePrefix}<%- queueName %>
11
- batchSize: 10
12
- <%_ function firstLetterUpperCase(text){
13
- return text.charAt(0).toUpperCase() + text.slice(1)
14
- } _%>
15
- <%_ function firstLetterLowerCase(str) {
16
- return str.charAt(0).toLowerCase() + str.slice(1)
17
- } _%>
10
+ batchSize: 10
@@ -18,7 +18,7 @@ along with this program. If not, see
18
18
 
19
19
 
20
20
 
21
- const statusFieldSharedLib = require('@izara_project/izara-core-library-status-field');
21
+ import statusFieldSharedLib from '@izara_project/izara-core-library-status-field';
22
22
 
23
23
  //(<optionalRequire>)
24
24
  //(</optionalRequire>)
@@ -15,7 +15,7 @@ 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
- const { S3Client, GetObjectCommand, DeleteObjectCommand, PutObjectCommand, CopyObjectCommand } = require('@aws-sdk/client-s3');
18
+ import { S3Client, GetObjectCommand, DeleteObjectCommand, PutObjectCommand, CopyObjectCommand } from '@aws-sdk/client-s3';
19
19
  const s3 = new S3Client({ region: 'us-east-2' });
20
20
 
21
21
  //(<optionalRequired>)
@@ -26,7 +26,7 @@ const { SOURCE_PATH, SAVE_FILE_NAME } = consts;
26
26
 
27
27
  const templatePath = path.join(
28
28
  __dirname,
29
- '../../../../resourceYaml/dynamodb/template.ejs'
29
+ '../../../../../resourceYaml/dynamodb/template.ejs'
30
30
  );
31
31
 
32
32
  function data(_izContext, srcPath) {