@izara_project/izara-market-library-service-schemas 1.0.2 → 1.0.4

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 (108) hide show
  1. package/package.json +5 -5
  2. package/src/GenerateCodeLibs/src/Consts.js +40 -0
  3. package/src/SourceManager/src/CreateSource.js +0 -1
  4. package/src/SourceManager/src/Utils.js +15 -1
  5. package/src/TemplateManager/src/FunctionYaml/HdrApi/data.js +170 -0
  6. package/src/TemplateManager/src/FunctionYaml/HdrApi/request.json +14 -0
  7. package/src/TemplateManager/src/FunctionYaml/HdrApi/template.ejs +33 -0
  8. package/src/TemplateManager/src/FunctionYaml/HdrDsq/data.js +180 -0
  9. package/src/TemplateManager/src/FunctionYaml/HdrDsq/request.json +19 -0
  10. package/src/TemplateManager/src/FunctionYaml/HdrDsq/template.ejs +30 -0
  11. package/src/TemplateManager/src/FunctionYaml/HdrInv/data.js +169 -0
  12. package/src/TemplateManager/src/{PerActionEndpoint/TemplateAndData/ResourceYaml/Lambda/Template/HdrInv.exampleData.js → FunctionYaml/HdrInv/example req.js } +3 -3
  13. package/src/TemplateManager/src/FunctionYaml/HdrInv/request.json +14 -0
  14. package/src/TemplateManager/src/{PerActionEndpoint/TemplateAndData/ResourceYaml/Lambda/Template/HdrInv.ejs → FunctionYaml/HdrInv/template.ejs} +5 -5
  15. package/src/TemplateManager/src/FunctionYaml/HdrSqs/data.js +182 -0
  16. package/src/TemplateManager/src/FunctionYaml/HdrSqs/request.json +19 -0
  17. package/src/TemplateManager/src/FunctionYaml/HdrSqs/template.ejs +30 -0
  18. package/src/TemplateManager/src/GenerateCode(Old).js +135 -0
  19. package/src/TemplateManager/src/GenerateCode.js +175 -15
  20. package/src/TemplateManager/src/PerActionEndpoint/Handler/HdrApi/data.js +100 -0
  21. package/src/TemplateManager/src/PerActionEndpoint/Handler/HdrApi/request.json +7 -0
  22. package/src/TemplateManager/src/PerActionEndpoint/Handler/HdrApi/template.ejs +76 -0
  23. package/src/TemplateManager/src/PerActionEndpoint/Handler/HdrDsq/data.js +109 -0
  24. package/src/TemplateManager/src/PerActionEndpoint/Handler/HdrDsq/request.json +7 -0
  25. package/src/TemplateManager/src/PerActionEndpoint/Handler/HdrDsq/template.ejs +105 -0
  26. package/src/TemplateManager/src/PerActionEndpoint/Handler/HdrInv/data.js +102 -0
  27. package/src/TemplateManager/src/PerActionEndpoint/Handler/HdrInv/request.json +7 -0
  28. package/src/TemplateManager/src/PerActionEndpoint/Handler/HdrInv/template.ejs +82 -0
  29. package/src/TemplateManager/src/PerActionEndpoint/Handler/HdrSqs/data.js +102 -0
  30. package/src/TemplateManager/src/PerActionEndpoint/Handler/HdrSqs/request.json +7 -0
  31. package/src/TemplateManager/src/PerActionEndpoint/Handler/HdrSqs/template.ejs +124 -0
  32. package/src/TemplateManager/src/PerActionEndpoint/Handler/testRequest.json +5 -0
  33. package/src/TemplateManager/src/PerActionEndpoint/MainFunction/Get/data.js +88 -0
  34. package/src/TemplateManager/src/PerActionEndpoint/MainFunction/Get/request.json +5 -0
  35. package/src/TemplateManager/src/PerActionEndpoint/MainFunction/Get/template.ejs +219 -0
  36. package/src/TemplateManager/src/ResourceYaml/dynamodb/awaitingMultipleStepData.js +98 -0
  37. package/src/TemplateManager/src/{MainResourcesYaml/TemplateAndData/DynamoDbMain/Data/MainDynamoDbYamlData.js → ResourceYaml/dynamodb/mainResourcePerObjectSchemaData.js} +66 -46
  38. package/src/TemplateManager/src/ResourceYaml/dynamodb/processLogicalAndFindData.js +103 -0
  39. package/src/TemplateManager/src/ResourceYaml/dynamodb/request.json +7 -0
  40. package/src/TemplateManager/src/ResourceYaml/dynamodb/template.ejs +31 -0
  41. package/src/TemplateManager/src/ResourceYaml/sns-in-sqs/defaultSnsInSqsForFindDataAndProcessLogical.js +81 -0
  42. package/src/TemplateManager/src/ResourceYaml/sns-in-sqs/request.json +4 -0
  43. package/src/TemplateManager/src/ResourceYaml/sns-in-sqs/snsAndSqsPerActiondata.js +108 -0
  44. package/src/TemplateManager/src/ResourceYaml/sns-in-sqs/snsTemplate.ejs +59 -0
  45. package/src/TemplateManager/src/ResourceYaml/sns-in-sqs/sqsTemplate.ejs +43 -0
  46. package/src/TemplateManager/src/ResourceYaml/sns-out/data.js +89 -0
  47. package/src/TemplateManager/src/ResourceYaml/sns-out/request.json +3 -0
  48. package/src/TemplateManager/src/ResourceYaml/sns-out/template.ejs +10 -0
  49. package/src/TemplateManager/src/UpdateRelationshipSchema/updateRalationshipComplete/functionYaml/data.js +151 -0
  50. package/src/TemplateManager/src/UpdateRelationshipSchema/updateRalationshipComplete/functionYaml/request.json +3 -0
  51. package/src/TemplateManager/src/UpdateRelationshipSchema/updateRalationshipComplete/functionYaml/template.ejs +33 -0
  52. package/src/TemplateManager/src/UpdateRelationshipSchema/updateRalationshipComplete/handler/HdrSqs/data.js +76 -0
  53. package/src/TemplateManager/src/UpdateRelationshipSchema/updateRalationshipComplete/handler/HdrSqs/template.ejs +127 -0
  54. package/src/TemplateManager/src/UpdateRelationshipSchema/updateRalationshipComplete/mainFunction/data.js +55 -0
  55. package/src/TemplateManager/src/UpdateRelationshipSchema/updateRalationshipComplete/mainFunction/request.json +1 -0
  56. package/src/TemplateManager/src/UpdateRelationshipSchema/updateRalationshipComplete/mainFunction/template.ejs +140 -0
  57. package/src/TemplateManager/src/UpdateRelationshipSchema/updateRalationshipComplete/sns-in-sqs/data.js +75 -0
  58. package/src/TemplateManager/src/UpdateRelationshipSchema/updateRalationshipComplete/sns-in-sqs/request.json +3 -0
  59. package/src/TemplateManager/src/UpdateRelationshipSchema/updateRalationshipComplete/sns-in-sqs/template.ejs +45 -0
  60. package/src/TemplateManager/src/UpdateRelationshipSchema/updateRalationshipComplete/sns-out/data.js +70 -0
  61. package/src/TemplateManager/src/UpdateRelationshipSchema/updateRalationshipComplete/sns-out/request.json +3 -0
  62. package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/functionYaml/HdrApi/data.js +127 -0
  63. package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/functionYaml/HdrApi/template.ejs +33 -0
  64. package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/functionYaml/HdrDsq/data.js +148 -0
  65. package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/functionYaml/HdrInv/data.js +125 -0
  66. package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/functionYaml/HdrSqs/data.js +148 -0
  67. package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/mainFunction/data.js +80 -0
  68. package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/mainFunction/request.json +1 -0
  69. package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/mainFunction/template.ejs +324 -0
  70. package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/perAction/HdrApi/data.js +72 -0
  71. package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/perAction/HdrApi/request.json +7 -0
  72. package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/perAction/HdrApi/template.ejs +120 -0
  73. package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/perAction/HdrDsq/data.js +73 -0
  74. package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/perAction/HdrDsq/request.json +7 -0
  75. package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/perAction/HdrDsq/template.ejs +167 -0
  76. package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/perAction/HdrInv/data.js +73 -0
  77. package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/perAction/HdrInv/request.json +5 -0
  78. package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/perAction/HdrInv/template.ejs +126 -0
  79. package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/perAction/HdrSqs/data.js +73 -0
  80. package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/perAction/HdrSqs/request.json +7 -0
  81. package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/perAction/HdrSqs/template.ejs +146 -0
  82. package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/perAction/request.json +31 -0
  83. package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/sns-in-sqs/data.js +91 -0
  84. package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/sns-in-sqs/request.json +3 -0
  85. package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/sns-out/data.js +70 -0
  86. package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/sns-out/request.json +3 -0
  87. package/src/TemplateManager/src/externalService/LambdaRole/data.js +193 -0
  88. package/src/TemplateManager/src/externalService/LambdaRole/request.json +18 -0
  89. package/src/TemplateManager/src/externalService/LambdaRole/template.ejs +56 -0
  90. package/src/TemplateManager/src/externalService/SnsTopicSubscriotions/data.js +96 -0
  91. package/src/TemplateManager/src/externalService/SnsTopicSubscriotions/request.json +12 -0
  92. package/src/TemplateManager/src/externalService/SnsTopicSubscriotions/template.ejs +10 -0
  93. package/src/TemplateManager/src/libs/Consts.js +32 -3
  94. package/src/TemplateManager/src/MainResourcesYaml/TemplateAndData/DynamoDbMain/Template/DynamoDb.ejs +0 -31
  95. package/src/TemplateManager/src/MainResourcesYaml/TemplateAndData/DynamoDbMain/Template/DynamoDb.exampleData.js +0 -12
  96. package/src/TemplateManager/src/PerActionEndpoint/CreateSourceData.js +0 -131
  97. package/src/TemplateManager/src/PerActionEndpoint/TemplateAndData/MainFunction/MainFunctionTemplate/Create.js +0 -18
  98. package/src/TemplateManager/src/PerActionEndpoint/TemplateAndData/MainFunction/MainFunctionTemplate/Delete.js +0 -18
  99. package/src/TemplateManager/src/PerActionEndpoint/TemplateAndData/MainFunction/MainFunctionTemplate/Get.js +0 -18
  100. package/src/TemplateManager/src/PerActionEndpoint/TemplateAndData/MainFunction/MainFunctionTemplate/Update.js +0 -18
  101. package/src/TemplateManager/src/PerActionEndpoint/TemplateAndData/ResourceYaml/Lambda/Data/LambdaYamlData.js +0 -166
  102. package/src/TemplateManager/src/PerActionEndpoint/TemplateAndData/ResourceYaml/Lambda/Template/HdrSqs.ejs +0 -0
  103. /package/src/TemplateManager/src/{MainResourcesYaml → ResourceYaml}/CreateSourceData.js +0 -0
  104. /package/src/TemplateManager/src/{PerActionEndpoint/DataPerActionEndpoint.js → UpdateRelationshipSchema/updateRalationshipComplete/handler/HdrSqs/request.json} +0 -0
  105. /package/src/TemplateManager/src/{PerActionEndpoint/TemplateAndData/Handler/Handler.js → UpdateRelationshipSchema/updateRelationship/functionYaml/HdrApi/request.json} +0 -0
  106. /package/src/TemplateManager/src/{PerActionEndpoint/TemplateAndData/MainFunction/MainFunctionTemplateData.js → UpdateRelationshipSchema/updateRelationship/functionYaml/HdrDsq/request.json} +0 -0
  107. /package/src/TemplateManager/src/{PerActionEndpoint/TemplateAndData/ResourceYaml/Lambda/Template/HdrApi.ejs → UpdateRelationshipSchema/updateRelationship/functionYaml/HdrInv/request.json} +0 -0
  108. /package/src/TemplateManager/src/{PerActionEndpoint/TemplateAndData/ResourceYaml/Lambda/Template/HdrDsq.ejs → UpdateRelationshipSchema/updateRelationship/functionYaml/HdrSqs/request.json} +0 -0
@@ -23,19 +23,75 @@ const { readFileSync } = require('fs');
23
23
 
24
24
  const {
25
25
  getAllLocalObjectSchemasWithHierarchy,
26
- getAllLocalRelationshipSchemas
26
+ getAllLocalRelationshipSchemas,
27
27
  } = require('@izara_project/izara-core-library-service-schemas/src/GetObjectSchema');
28
28
 
29
29
 
30
+ const {
31
+ getGraphServiceNameFromGraphServerTagWithCache
32
+ } = require('@izara_project/izara-core-library-service-schemas/src/ServiceConfig');
30
33
 
31
34
  const { createSource } = require("../../SourceManager/src/CreateSource");
32
35
  const { deleteFileInDir } = require("../../SourceManager/src/Utils");
36
+ // create handler function
37
+ const perActionHdrInvData = require("./PerActionEndpoint/Handler/HdrInv/data");
38
+ const perActionHdrApiData = require("./PerActionEndpoint/Handler/HdrApi/data");
39
+ const perActionHdrSqsData = require("./PerActionEndpoint/Handler/HdrSqs/data");
40
+ const perActionHdrDsqData = require("./PerActionEndpoint/Handler/HdrDsq/data");
41
+
42
+ // create Main funcion
43
+ const mainFunctionGetData = require('./PerActionEndpoint/MainFunction/Get/data');
44
+
45
+ // create function.yaml
46
+ const functionGetYamlDataHdrInv = require('./FunctionYaml/HdrInv/data');
47
+ const functionGetYamlDataHdrApi = require('./FunctionYaml/HdrApi/data');
48
+ const functionGetYamlDataHdrSqs = require('./FunctionYaml/HdrSqs/data');
49
+ const functionGetYamlDataHdrDsq = require('./FunctionYaml/HdrDsq/data');
50
+
51
+
52
+ // create Main resource
53
+ const { createSourceDataDynamoDB } = require('./ResourceYaml/dynamodb/mainResourcePerObjectSchemaData');
54
+ const { createDefaultSourceDataDynamoDB } = require('./ResourceYaml/dynamodb/processLogicalAndFindData');
55
+ const { createSourceSnsAndSqs } = require('./ResourceYaml/sns-in-sqs/snsAndSqsPerActiondata');
56
+ const createDataForCreateSourceSnsOut = require('./ResourceYaml/sns-out/data')
57
+ const createFindDataAndProcessLogicalDefaultSnsInSqs = require('./ResourceYaml/sns-in-sqs/defaultSnsInSqsForFindDataAndProcessLogical');
58
+ const { createAwaitingMultipleStepDynamoDbData } = require('./ResourceYaml/dynamodb/awaitingMultipleStepData');
59
+
60
+ // create External Service
61
+ const createExternalLambdaRole = require('./externalService/LambdaRole/data');
62
+ const createExternalSnsSubscriptions = require('./externalService/SnsTopicSubscriotions/data');
63
+
64
+ // create update relationship schema
65
+ // const createUpdateRelationshipFunctionYamlHdrApi = require('./UpdateRelationshipSchema/updateRelationship/functionYaml/HdrApi/data')
66
+ const createUpdateRelationshipFunctionYamlHdrInv = require('./UpdateRelationshipSchema/updateRelationship/functionYaml/HdrInv/data');
67
+ const createUpdateRelationshipFunctionYamlHdrDsq = require('./UpdateRelationshipSchema/updateRelationship/functionYaml/HdrDsq/data');
68
+ const createUpdateRelationshipFunctionYamlHdrSqs = require('./UpdateRelationshipSchema/updateRelationship/functionYaml/HdrSqs/data');
69
+
70
+ // create main function updateRelationship schema main function
71
+ const createUpdateRelationshipSchemaMainFunction = require('./UpdateRelationshipSchema/updateRelationship/mainFunction/data');
72
+
73
+ // create handler Update Relationship schema
74
+ const createUpdateRelationshipSchemaHdrInv = require('./UpdateRelationshipSchema/updateRelationship/perAction/HdrInv/data');
75
+ // const createUpdateRelationshipSchemaHdrApi = require('./UpdateRelationshipSchema/updateRelationship/perAction/HdrApi/data');
76
+ const createUpdateRelationshipSchemaHdrDsq = require('./UpdateRelationshipSchema/updateRelationship/perAction/HdrDsq/data');
77
+ const createUpdateRelationshipSchemaHdrSqs = require('./UpdateRelationshipSchema/updateRelationship/perAction/HdrSqs/data');
33
78
 
34
- const perAction = require("./PerActionEndpoint/CreateSourceData");
79
+ // create sns for update relationship schema
80
+ const createUpdateRelationshipSchemaSnsInSqsResource = require('./UpdateRelationshipSchema/updateRelationship/sns-in-sqs/data');
81
+ // const createUpdateRelationshipSchemaSnsOutResource = require('./UpdateRelationshipSchema/updateRelationship/sns-out/data');
35
82
 
36
- const mainResources = require("./MainResourcesYaml/CreateSourceData");
83
+ // create updateRelationshipFunctionYaml
84
+ const createUpdateRelationshipSchemaCompleteYaml = require('./UpdateRelationshipSchema/updateRalationshipComplete/functionYaml/data');
37
85
 
86
+ // create update relationship hdrSqs
87
+ const createUpdateRelationshipSchemaCompleteHdrSqs = require('./UpdateRelationshipSchema/updateRalationshipComplete/handler/HdrSqs/data');
38
88
 
89
+ // create sns-in-sqs resource yaml updateRelationshipSchemaComplete
90
+ const createUpdateRelationshipSchemaCompleteSnsInSqs = require('./UpdateRelationshipSchema/updateRalationshipComplete/sns-in-sqs/data');
91
+
92
+ const createUpdateRelationshipSchemaCompleteSnsOut = require('./UpdateRelationshipSchema/updateRalationshipComplete/sns-out/data');
93
+
94
+ const createUpdateRelationshipSchemaCompleteMainFunction = require('./UpdateRelationshipSchema/updateRalationshipComplete/mainFunction/data');
39
95
  /**
40
96
  *
41
97
  * get template and send to
@@ -59,16 +115,22 @@ async function generateCodeWithTemplate(_izContext, objSchemaPath) {
59
115
  const GENERATECODE_SOURCE_PATH = {
60
116
  appYaml: join(saveFilePath, `../sls_yaml/generatedCode/source/`),
61
117
  resourceYaml: join(saveFilePath, `../../resource/sls_yaml/generatedCode/source/`),
62
- lambdaPerObjectTypePath: join(saveFilePath, `/generatedCode/lambdaPerObjectType/source/`), // test
118
+ lambdaPerAction: join(saveFilePath, '../src/generatedCode/ObjectTypePerActionEndpoint/source/'),
119
+ externalService: join(saveFilePath, '../initial_setup/generatedCode/source/'),
120
+ resourceLocation: join(saveFilePath, 'src/generatedCode/perAction/source/'),
63
121
  lamdaPerCombindActionPath: join(saveFilePath, `/generatedCode/lamdaPerCombindAction/source/`), // test
122
+ lambdaPerObjectTypePath: join(saveFilePath, `/generatedCode/lambdaPerObjectType/source/`), // test
123
+ updateRelationship: join(saveFilePath, `../src/generatedCode/RelationshipPerAction/source/`),
64
124
  };
65
125
 
66
126
 
67
127
  // from app/src/shcemas
68
128
  let allObjSchemas = await getAllLocalObjectSchemasWithHierarchy(_izContext, objSchemaPath);
129
+ // _izContext.logger.debug("allObjSchemas: ", allObjSchemas)
69
130
 
70
131
  const allObjectRelationships = await getAllLocalRelationshipSchemas(_izContext, objSchemaPath);
71
132
 
133
+ // _izContext.logger.debug("allObjectRelationships: ", allObjectRelationships)
72
134
  /*
73
135
  Should we generateCode with objectSchema that not in hierarchy or not?
74
136
  Should use objectSchema with hierarchy because we use storageResource of parent to create lambda iam role in .yml file
@@ -77,45 +139,143 @@ async function generateCodeWithTemplate(_izContext, objSchemaPath) {
77
139
  let createSourceParams = [];
78
140
 
79
141
  for (const relTag in allObjectRelationships) {
80
- const relTagData = allObjectRelationships[relTag];
142
+ // const relTagData = allObjectRelationships[relTag];
81
143
 
82
144
  // create main resource per relationshipSchema
83
- const createSourceMainResourcesRelSchema = mainResources.createSourceDataRelSchema(_izContext, { [relTag]: relTagData }, saveFilePath);
84
- console.log("createSourceMainResourcesRelSchema: ", createSourceMainResourcesRelSchema);
145
+ // const createSourceMainResourcesRelSchema = mainResources.createSourceDataRelSchema(_izContext, { [relTag]: relTagData }, saveFilePath);
146
+ // console.log("createSourceMainResourcesRelSchema: ", createSourceMainResourcesRelSchema);
85
147
 
86
- createSourceParams = createSourceParams.concat(createSourceMainResourcesRelSchema);
148
+ // createSourceParams = createSourceParams.concat(createSourceMainResourcesRelSchema);
87
149
  }
88
150
 
89
-
90
- //
151
+ // create External service
152
+ const createFunctionIamRole = await createExternalLambdaRole(_izContext, allObjSchemas.records, allObjectRelationships, saveFilePath);
153
+ const createSnsSubscription = await createExternalSnsSubscriptions(_izContext, allObjectRelationships, saveFilePath);
91
154
  for (let objectSchema of allObjSchemas.records) {
92
155
 
93
156
  // create main resource per objectSchema
94
- let createSourceMainResourcesObjectSchema = mainResources.createSourceDataObjectSchema(_izContext, objectSchema, saveFilePath);
157
+ // const createSourceMainResourcesObjectSchema = mainResources.createSourceDataObjectSchema(_izContext, objectSchema, saveFilePath);
95
158
  // console.log("createSourceMainResourcesObjectSchema: ", createSourceMainResourcesObjectSchema);
96
159
 
97
160
  // mainFunction, handlerFunction, resourceYaml per action
98
- let createSourcePerAction = perAction.createSourceDataObjectSchema(_izContext, objectSchema, saveFilePath);
161
+ // let createSourcePerAction = perAction.createSourceDataObjectSchema(_izContext, objectSchema, saveFilePath);
99
162
  // console.log("createSourcePerAction: ", createSourcePerAction)
100
163
 
164
+ // generate handler perAction
165
+ const createSourceHdrInv = perActionHdrInvData(_izContext, objectSchema, saveFilePath);
166
+ const createSourceHdrApi = perActionHdrApiData(_izContext, objectSchema, saveFilePath);
167
+ const createSourceHdrSqs = perActionHdrSqsData(_izContext, objectSchema, saveFilePath);
168
+ const createSourceHdrDsq = perActionHdrDsqData(_izContext, objectSchema, saveFilePath);
169
+
170
+ // wrap Handler Function
171
+ const createSourceHandler = [...createSourceHdrInv, ...createSourceHdrApi, ...createSourceHdrSqs, ...createSourceHdrDsq];
172
+
173
+ // generate main function
174
+ const createMainFunctionGet = await mainFunctionGetData(_izContext, objectSchema, saveFilePath);
101
175
 
176
+ // generate functionYaml File
177
+ const createFunctionGetYamlHdrInv = functionGetYamlDataHdrInv(_izContext, objectSchema, saveFilePath);
178
+ const createFunctionGetYamlHdrApi = functionGetYamlDataHdrApi(_izContext, objectSchema, saveFilePath);
179
+ const createFunctionGetYamlHdrSqs = functionGetYamlDataHdrSqs(_izContext, objectSchema, saveFilePath);
180
+ const createFunctionGetYamlHdrDsq = functionGetYamlDataHdrDsq(_izContext, objectSchema, saveFilePath);
102
181
 
103
- // console.log("createSourceParams begore concat: ", createSourceParams);
182
+ // wrapMain Function
183
+ const createFunctionYaml = [...createFunctionGetYamlHdrApi, ...createFunctionGetYamlHdrDsq, ...createFunctionGetYamlHdrInv, ...createFunctionGetYamlHdrSqs];
104
184
 
105
- createSourceParams = createSourceParams.concat([...createSourcePerAction, ...createSourceMainResourcesObjectSchema]);
185
+ // generate Resource ..via dynamoDb sns-in-sqs sns-put
186
+ const createResourceDynamo = createSourceDataDynamoDB(_izContext, objectSchema, saveFilePath);
187
+ const createResourceSnsInSqs = createSourceSnsAndSqs(_izContext, objectSchema, saveFilePath);
188
+ const createResourceSnsOut = createDataForCreateSourceSnsOut(_izContext, objectSchema, saveFilePath)
189
+
190
+ // wrap main Resource
191
+ const createMainResource = [...createResourceDynamo, ...createResourceSnsInSqs, ...createResourceSnsOut];
192
+
193
+ createSourceParams = createSourceParams.concat([
194
+ // ...createSourceMainResourcesObjectSchema,
195
+ ...createSourceHandler, // create handler function
196
+ ...createMainFunctionGet, // create main function
197
+ ...createFunctionYaml, // create function.yaml
198
+ ...createMainResource, // create resource yaml
199
+ ]);
106
200
 
107
201
  // console.log("createSourceParams after concat: ", createSourceParams);
108
202
  }
109
203
 
110
204
 
205
+ // create default data resource such as findData ProcessLogical and awaitingMultipleStep
206
+ const createResourceFindDataAndProcessLogical = createDefaultSourceDataDynamoDB(_izContext, saveFilePath);
207
+ const createResourceAwaitingMultipleStep = createAwaitingMultipleStepDynamoDbData(_izContext, saveFilePath);
208
+ const createResourceDefaultSnsInSqsFindDataAndProcessLogical = createFindDataAndProcessLogicalDefaultSnsInSqs(_izContext, saveFilePath);
209
+
210
+ const createMainResourceDefault = [...createResourceFindDataAndProcessLogical, ...createResourceDefaultSnsInSqsFindDataAndProcessLogical, ...createResourceAwaitingMultipleStep];
211
+
212
+ // create function yaml for update relationshipSchema per handler
213
+ const createYamlUpdateRelationshipSchemaHdrSqs = createUpdateRelationshipFunctionYamlHdrSqs(_izContext, saveFilePath);
214
+ const createYamlUpdateRelationshipSchemaHdrInv = createUpdateRelationshipFunctionYamlHdrInv(_izContext, saveFilePath);
215
+ const createYamlUpdateRelationshipSchemaHdrDsq = createUpdateRelationshipFunctionYamlHdrDsq(_izContext, saveFilePath);
216
+ // const createYamlUpdateRelationshipSchemaHdrApi = createUpdateRelationshipFunctionYamlHdrApi(_izContext, saveFilePath)
217
+ const createYamlUpdateRelationshipSchema = [...createYamlUpdateRelationshipSchemaHdrSqs, ...createYamlUpdateRelationshipSchemaHdrInv, ...createYamlUpdateRelationshipSchemaHdrDsq];
218
+
219
+ // create main function
220
+ const createMainFunctionUpdateRelationshipSchema = createUpdateRelationshipSchemaMainFunction(_izContext, saveFilePath);
221
+
222
+ // create handler function for each updateRelationshipSchema
223
+ const createUpdateRelationshipSchemaPerActionHdrInv = createUpdateRelationshipSchemaHdrInv(_izContext, saveFilePath);
224
+ // const createUpdateRelationshipSchemaPerActionHdrApi = createUpdateRelationshipSchemaHdrApi(_izContext, saveFilePath);
225
+ const createUpdateRelationshipSchemaPerActionHdrDsq = createUpdateRelationshipSchemaHdrDsq(_izContext, saveFilePath);
226
+ const createUpdateRelationshipSchemaPerActionHdrSqs = createUpdateRelationshipSchemaHdrSqs(_izContext, saveFilePath);
227
+
228
+ const createUpdateRelationshipSchemaPerAction = [...createUpdateRelationshipSchemaPerActionHdrInv,
229
+ // ...createUpdateRelationshipSchemaPerActionHdrApi,
230
+ ...createUpdateRelationshipSchemaPerActionHdrDsq, ...createUpdateRelationshipSchemaPerActionHdrSqs];
231
+
232
+ // create resource sns-in-sqs for update relationship schema
233
+ const createUpdateRelationshipSchemaSnsIn = createUpdateRelationshipSchemaSnsInSqsResource(_izContext, saveFilePath);
234
+ // const createUpdateRelationshipSchemaSnsOut = createUpdateRelationshipSchemaSnsOutResource(_izContext, saveFilePath);
235
+
236
+ const createResourceUpdateRelationshipSchema = [...createUpdateRelationshipSchemaSnsIn,];
237
+
238
+ // warp function updateRelationshipSchemaData
239
+ const createUpdateRelationshipSchemaData = [...createUpdateRelationshipSchemaPerAction, ...createResourceUpdateRelationshipSchema, ...createMainFunctionUpdateRelationshipSchema]
240
+
241
+ // create UpdateRelationshipComplete Main Function
242
+ const createUpdateRelationshipSchemaCompleteMain = createUpdateRelationshipSchemaCompleteMainFunction(_izContext, saveFilePath);
243
+
244
+ // create function yaml updateRelationshipComplete
245
+ const createUpdateRelationshipSchemaCompleteFunctionYaml = createUpdateRelationshipSchemaCompleteYaml(_izContext, saveFilePath)
246
+
247
+ // create handler updateRelationshipSchemaComplete HdrSqs
248
+ const createUpdateRelationshipSchemaCompleteHandler = createUpdateRelationshipSchemaCompleteHdrSqs(_izContext, saveFilePath)
249
+
250
+ // create resource yaml updateRelationshipSchemaComplete
251
+ const createUpdateRelationshipSchemaCompleteSnsInSqsResource = createUpdateRelationshipSchemaCompleteSnsInSqs(_izContext, saveFilePath)
252
+ const createUpdateRelationshipSchemaCompleteSnsOutResource = createUpdateRelationshipSchemaCompleteSnsOut(_izContext, saveFilePath)
253
+
254
+ // warp function updateRelationshipSchemaCompleteData
255
+ const createUpdateRelationshipSchemaCompleteData = [...createUpdateRelationshipSchemaCompleteFunctionYaml, ...createUpdateRelationshipSchemaCompleteHandler, ...createUpdateRelationshipSchemaCompleteSnsInSqsResource,
256
+ ...createUpdateRelationshipSchemaCompleteSnsOutResource, ...createUpdateRelationshipSchemaCompleteMain]
257
+
258
+
259
+
260
+
261
+ createSourceParams.push(...createMainResourceDefault, ...createYamlUpdateRelationshipSchema,
262
+ ...createUpdateRelationshipSchemaData,
263
+ ...createUpdateRelationshipSchemaCompleteData,
264
+ createFunctionIamRole,
265
+ createSnsSubscription
266
+ );
267
+ // console.log("createSourceParams", createSourceParams);
268
+
111
269
  // delete file .yml before start to prevent confilct of data
112
270
  for (let folderPathToEmpty of Object.keys(GENERATECODE_SOURCE_PATH)) {
113
271
  await deleteFileInDir(GENERATECODE_SOURCE_PATH[folderPathToEmpty]);
114
272
  }
115
273
 
116
-
274
+ // console.log("createSourceParams: ", createSourceParams)
117
275
  // start create source
118
276
  for (let { templatePath, templateData, setting } of createSourceParams) {
277
+ // console.log("templatePath in GenerateCode", templatePath);
278
+ // console.log("setting.savePath in GenerateCode", setting.savePath);
119
279
  await createSource(
120
280
  readFileSync(templatePath, 'utf8'),
121
281
  templateData,
@@ -0,0 +1,100 @@
1
+ /*
2
+ Copyright (C) 2020 Sven Mason <http://izara.io>
3
+
4
+ This program is free software: you can redistribute it and/or modify
5
+ it under the terms of the GNU Affero General Public License as
6
+ published by the Free Software Foundation, either version 3 of the
7
+ License, or (at your option) any later version.
8
+
9
+ This program is distributed in the hope that it will be useful,
10
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ GNU Affero General Public License for more details.
13
+
14
+ You should have received a copy of the GNU Affero General Public License
15
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
16
+ */
17
+
18
+ 'use strict';
19
+ const path = require('path');
20
+ const fs = require('fs');
21
+
22
+ const { ACTIONS, HANDLER } = require('@izara_project/izara-core-library-service-schemas/src/Consts')
23
+
24
+ const { firstLetterLowerCase: lowerCase, firstLetterUpperCase: upperCase, firstLetterUpperCase } = require("../../../../../MainLibs/src/Utils")
25
+ const { DEFAULT_HANDLER_PER_ACTION, SOURCE_PATH } = require("../../../libs/Consts");
26
+
27
+ const templatePath = path.join(__dirname, "./template.ejs")
28
+
29
+ /**
30
+ * receive objectSchema
31
+ * create data for hdrInv template
32
+ *
33
+ * @param {Object} objectSchema
34
+ * @return {{ templatePath, templateData, setting } }
35
+ */
36
+ function data(_izContext, objectSchema, srcPath) {
37
+ let createSourceArray = [];
38
+
39
+ for (const action of Object.values(ACTIONS)) {
40
+ if (objectSchema.overWriteHandlers?.[action]) {
41
+ // if have overWriteHander of action check hdrInv inside
42
+ if (objectSchema.overWriteHandlers[action].includes(HANDLER.hdrApi)) {
43
+ // create template data
44
+ const createSourceParam = createParamForCreateSource(objectSchema, action, srcPath)
45
+ createSourceArray.push(createSourceParam)
46
+ }
47
+ } else {
48
+ // if not have overWriteHander of action will use default handler
49
+ const defaultHandler = DEFAULT_HANDLER_PER_ACTION[action]
50
+ if (defaultHandler.includes(HANDLER.hdrApi)) {
51
+ // create template data and object for create source
52
+ const createSourceParam = createParamForCreateSource(objectSchema, action, srcPath)
53
+ createSourceArray.push(createSourceParam)
54
+ }
55
+ }
56
+ }
57
+
58
+ return createSourceArray;
59
+ }
60
+
61
+
62
+ function createParamForCreateSource(objectSchema, action, srcPath) {
63
+ let objectType = objectSchema.objectType;
64
+ let actionHandler = action;
65
+ let functionName = objectType + firstLetterUpperCase(action);
66
+ return {
67
+ templatePath: templatePath,
68
+ templateData: {
69
+ functionName: functionName,
70
+ objectType: objectType,
71
+ actionHandler: actionHandler,
72
+ isCreateMainFunction: (objectSchema.overwriteGeneratedMainFunction?.length
73
+ && objectSchema.overwriteGeneratedMainFunction.includes(action)
74
+ ) ? true : false,
75
+ },
76
+ setting: {
77
+ savePath: path.join(srcPath, SOURCE_PATH.lambdaPerAction),
78
+ saveFileName: `${upperCase(objectSchema.objectType)}${upperCase(action)}_HdrApi`,
79
+ fileExtension: '.js',
80
+ isAppend: false
81
+ }
82
+ }
83
+ }
84
+
85
+
86
+ // [
87
+ // {
88
+ // templatePath: '/home/toughnut/BasProgram/empty-service-template/app/node_modules/@izara_project/izara-market-library-service-schemas/src/TemplateManager/src/MainResourcesYaml/TemplateAndData/DynamoDbMain/Template/DynamoDb.ejs',
89
+ // templateData: { tableName: 'ObjectTypeSingle', attributes: [Array] },
90
+ // setting: {
91
+ // savePath: '/generatedCode/source/',
92
+ // saveFileName: 'ObjectTypeGet',
93
+ // fileExtension: '.js',
94
+ // isAppend: false
95
+ // }
96
+ // }
97
+ // ]
98
+
99
+
100
+ module.exports = data;
@@ -0,0 +1,7 @@
1
+ {
2
+ "objectType": "objectType",
3
+ "action": "get",
4
+ "mainFunction": "xxx",
5
+ "mainFunctionFile": "directoryOfMainFunction",
6
+ "isCreateMainByDev": "boolean"
7
+ }
@@ -0,0 +1,76 @@
1
+ /*
2
+ Copyright (C) 2020 Sven Mason <http://izara.io>
3
+
4
+ This program is free software: you can redistribute it and/or modify
5
+ it under the terms of the GNU Affero General Public License as
6
+ published by the Free Software Foundation, either version 3 of the
7
+ License, or (at your option) any later version.
8
+
9
+ This program is distributed in the hope that it will be useful,
10
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ GNU Affero General Public License for more details.
13
+
14
+ You should have received a copy of the GNU Affero General Public License
15
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
16
+ */
17
+
18
+ 'use strict';
19
+ const izara = require("@izara_project/izara-middleware");
20
+ const middleware = izara.middlewareHandler;
21
+ const callingFlowSharedLib = require('@izara_project/izara-shared/src/CallingFlowSharedLib')
22
+ const {
23
+ validateSchemaMiddleware
24
+ } = require('@izara_project/izara-market-library-service-schemas/src/GenerateCodeLibs/src/GenerateCodeLibs');
25
+
26
+ <%_ if (isCreateMainFunction == true) { _%>
27
+ // user generate main function
28
+ <%_ } else { %>
29
+ const <%- functionName %> =require('./<%- firstLetterUpperCase(objectType) %><%- firstLetterUpperCase(actionHandler) %>_Main')
30
+ <%_ } _%>
31
+
32
+ //(<globalVarible>
33
+ //</globalVarible>)
34
+
35
+ //validate event params in middleware before into main function
36
+ validateSchemaMiddleware(
37
+ middleware,
38
+ "<%- firstLetterUpperCase(objectType) %>",
39
+ "<%- actionHandler %>"
40
+ //(<validateSchemaSetting>
41
+ //</validateSchemaSetting>)
42
+ )
43
+ // if need to validate authorizer or additional params , add code to hook tag below
44
+
45
+ //(<afterValidateWith>)
46
+ //(</afterValidateWith>)
47
+
48
+
49
+ module.exports.main = middleware.wrap(async (event, context, callback) => {
50
+ event._izContext.logger.debug('Event:', event);
51
+ try {
52
+ // invoke LambdaFunction
53
+ let lambdaFunctionResponse = await <%- functionName %>.<%- functionName %>Main(
54
+ event._izContext, // correlationId/logger/integrationTestDetail/uniqueRequestId/userId
55
+ event,
56
+ );
57
+
58
+ // return error to client
59
+ if (lambdaFunctionResponse instanceof Error) {
60
+ return (izara.response.failure(lambdaFunctionResponse));
61
+ }
62
+
63
+ // return success to client
64
+ return (izara.response.success(lambdaFunctionResponse));
65
+
66
+ } catch (err) {
67
+ event._izContext.logger.error('Error, <%- functionName %>Main: ', err);
68
+ return (izara.response.failure(err));
69
+ }
70
+ });
71
+ <%_ function firstLetterUpperCase(text){
72
+ return text.charAt(0).toUpperCase() + text.slice(1)
73
+ } _%>
74
+ <%_ function firstLetterLowerCase(str) {
75
+ return str.charAt(0).toLowerCase() + str.slice(1)
76
+ } _%>
@@ -0,0 +1,109 @@
1
+ /*
2
+ Copyright (C) 2020 Sven Mason <http://izara.io>
3
+
4
+ This program is free software: you can redistribute it and/or modify
5
+ it under the terms of the GNU Affero General Public License as
6
+ published by the Free Software Foundation, either version 3 of the
7
+ License, or (at your option) any later version.
8
+
9
+ This program is distributed in the hope that it will be useful,
10
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ GNU Affero General Public License for more details.
13
+
14
+ You should have received a copy of the GNU Affero General Public License
15
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
16
+ */
17
+
18
+ 'use strict';
19
+ const path = require('path');
20
+ const fs = require('fs');
21
+
22
+ const { ACTIONS, HANDLER } = require('@izara_project/izara-core-library-service-schemas/src/Consts')
23
+
24
+
25
+ const { firstLetterLowerCase: lowerCase, firstLetterUpperCase: upperCase, firstLetterUpperCase } = require("../../../../../MainLibs/src/Utils")
26
+ const { DEFAULT_HANDLER_PER_ACTION, SOURCE_PATH } = require("../../../libs/Consts");
27
+
28
+
29
+ const templatePath = path.join(__dirname, "./template.ejs")
30
+
31
+ /**
32
+ * receive objectSchema
33
+ * create data for hdrInv template
34
+ *
35
+ * @param {Object} objectSchema
36
+ * @return {{ templatePath, templateData, setting } }
37
+ */
38
+ function data(_izContext, objectSchema, srcPath) {
39
+ let createSourceArray = [];
40
+
41
+ for (const action of Object.values(ACTIONS)) {
42
+ if (objectSchema.overWriteHandlers?.[action]) {
43
+ // if have overWriteHander of action check hdrInv inside
44
+ if (objectSchema.overWriteHandlers[action].includes(HANDLER.hdrDsq)) {
45
+ // create template data
46
+ const createSourceParam = createParamForCreateSource(objectSchema, action, srcPath)
47
+ createSourceArray.push(createSourceParam)
48
+ }
49
+ } else {
50
+ // if not have overWriteHander of action will use default handler
51
+ const defaultHandler = DEFAULT_HANDLER_PER_ACTION[action]
52
+ if (defaultHandler.includes(HANDLER.hdrDsq)) {
53
+ // create template data and object for create source
54
+ const createSourceParam = createParamForCreateSource(objectSchema, action, srcPath)
55
+ createSourceArray.push(createSourceParam)
56
+ }
57
+ }
58
+ }
59
+
60
+ return createSourceArray;
61
+ }
62
+
63
+
64
+ function createParamForCreateSource(objectSchema, action, srcPath) {
65
+ let objectType = objectSchema.objectType;
66
+ let actionHandler = action;
67
+ let functionName = objectType + upperCase(action);
68
+ let queueName = objectType + firstLetterUpperCase(action) + "HdrDsq";
69
+ let identifiers = [];
70
+ for (const identifier of Object.values(objectSchema.identifiers)) {
71
+ identifiers.push(identifier.fieldName)
72
+ }
73
+ return {
74
+ templatePath: templatePath,
75
+ templateData: {
76
+ functionName: functionName,
77
+ objectType: objectType,
78
+ actionHandler: actionHandler,
79
+ queueName,
80
+ identifiers,
81
+ isCreateMainFunction: (objectSchema.overwriteGeneratedMainFunction?.length
82
+ && objectSchema.overwriteGeneratedMainFunction.includes(action)
83
+ ) ? true : false,
84
+ },
85
+ setting: {
86
+ savePath: path.join(srcPath, SOURCE_PATH.lambdaPerAction),
87
+ saveFileName: `${upperCase(objectSchema.objectType)}${upperCase(action)}_HdrDsq`,
88
+ fileExtension: '.js',
89
+ isAppend: false
90
+ }
91
+ }
92
+ }
93
+
94
+
95
+ // [
96
+ // {
97
+ // templatePath: '/home/toughnut/BasProgram/empty-service-template/app/node_modules/@izara_project/izara-market-library-service-schemas/src/TemplateManager/src/MainResourcesYaml/TemplateAndData/DynamoDbMain/Template/DynamoDb.ejs',
98
+ // templateData: { tableName: 'ObjectTypeSingle', attributes: [Array] },
99
+ // setting: {
100
+ // savePath: '/generatedCode/source/',
101
+ // saveFileName: 'ObjectTypeGet',
102
+ // fileExtension: '.js',
103
+ // isAppend: false
104
+ // }
105
+ // }
106
+ // ]
107
+
108
+
109
+ module.exports = data;
@@ -0,0 +1,7 @@
1
+ {
2
+ "objectType": "objectType",
3
+ "action": "get",
4
+ "mainFunction": "xxx",
5
+ "mainFunctionFile": "directoryOfMainFunction",
6
+ "isCreateMainByDev": "boolean"
7
+ }
@@ -0,0 +1,105 @@
1
+ /*
2
+ Copyright (C) 2020 Sven Mason <http://izara.io>
3
+
4
+ This program is free software: you can redistribute it and/or modify
5
+ it under the terms of the GNU Affero General Public License as
6
+ published by the Free Software Foundation, either version 3 of the
7
+ License, or (at your option) any later version.
8
+
9
+ This program is distributed in the hope that it will be useful,
10
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ GNU Affero General Public License for more details.
13
+
14
+ You should have received a copy of the GNU Affero General Public License
15
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
16
+ */
17
+
18
+ 'use strict';
19
+ const izara = require("@izara_project/izara-middleware");
20
+ const middleware = izara.middlewareHandler;
21
+ const callingFlowSharedLib = require('@izara_project/izara-shared/src/CallingFlowSharedLib');
22
+ const recordHandlerSharedLib = require('@izara_project/izara-shared').recordHandlerSharedLib;
23
+ const {
24
+ validateSchemaMiddleware
25
+ } = require('@izara_project/izara-market-library-service-schemas/src/GenerateCodeLibs/src/GenerateCodeLibs');
26
+ const Logger = require('@izara_project/izara-core-library-logger');
27
+
28
+ <%_ if (isCreateMainFunction == true) { _%>
29
+ // user generate main function
30
+ <%_ } else { %>
31
+ const <%- functionName %> =require('./<%- firstLetterUpperCase(objectType) %><%- firstLetterUpperCase(actionHandler) %>_Main')
32
+ <%_ } _%>
33
+
34
+ const perRecordsValidatorSchema = {
35
+ type: "object",
36
+ required: ['identifiers'],
37
+ properties: {
38
+ identifiers: {
39
+ type: "object"
40
+ }
41
+ }
42
+ }
43
+
44
+ module.exports.main = middleware.wrap(async(event,context,callback) => {
45
+
46
+ try {
47
+
48
+ let recordPromises = []; // final return
49
+
50
+ // loop each record and send to mainFunction
51
+ await Promise.all(event.Records.map(async record => { // promise.all for map() function
52
+
53
+ // --- reforming record.body for Dsq request
54
+ record = recordHandlerSharedLib.reformatDsqMessage(record._izContext, record);
55
+ record._izContext.logger.debug('record LambdaFunctionHdrDsq after reform', record);
56
+
57
+ let passOnProperties = []
58
+
59
+ // --- validate message (and MessageAttributes)
60
+ await recordHandlerSharedLib.validateRecord(
61
+ record, // one record will send to mainFunction
62
+ "<%- queueName %>", // queue name that need to retry or send to dlq
63
+ perRecordsValidatorSchema, // schema for record.Message
64
+ // messageAttributeValidatorSchema // ----- for msgAttr default is null -> do not send this parameter if not want to validate msgAtt
65
+ );
66
+
67
+ // add argument (to invoke lambda) to passOnProperties[]
68
+ passOnProperties.push(record.body.Message)
69
+ record._izContext.logger.debug('passOnProperties in handler', passOnProperties);
70
+
71
+ // call recordHandlerSharedLib.recordHandler with 3 parameters and return promise(resolve)
72
+ let recordPromise = recordHandlerSharedLib.recordHandler(
73
+ record, // one record will send to mainFunction
74
+ <%- functionName %>.<%- functionName %>Main, // mainFunction that need to invoke.
75
+ "<%- queueName %>", // queue name that need to retry or send to dlq
76
+ passOnProperties, // all parameters that mainFunction needed.
77
+ );
78
+ record._izContext.logger.debug('after recordPromise in handler');
79
+ recordPromises.push(recordPromise); // push promise to recordPromises
80
+ })) //end record
81
+
82
+ Logger.debug('before Promise.all(recordPromises) in handler');
83
+ try {
84
+ await Promise.all(recordPromises); // await all promises
85
+ return event.Records // return all for local test
86
+ } catch {
87
+ Logger.debug('Promise.all(recordPromises) in handler threw error (at least one record did no resolve)');
88
+ }
89
+ Logger.debug('after Promise.all(recordPromises) in handler');
90
+ } catch (err) {
91
+ Logger.error('Unhandled Error, <%- firstLetterUpperCase(objectType) %><%- firstLetterUpperCase(actionHandler) %>Dsq :', err);
92
+ throw (err);
93
+ }
94
+ })
95
+
96
+
97
+
98
+
99
+
100
+ <%_ function firstLetterUpperCase(text){
101
+ return text.charAt(0).toUpperCase() + text.slice(1)
102
+ } _%>
103
+ <%_ function firstLetterLowerCase(str) {
104
+ return str.charAt(0).toLowerCase() + str.slice(1)
105
+ } _%>