@izara_project/izara-market-library-service-schemas 1.0.32 → 1.0.34

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 (65) hide show
  1. package/package.json +1 -1
  2. package/src/GenerateCodeLibs/src/Consts.js +2 -1
  3. package/src/GenerateCodeLibs/src/GenerateCodeLibs.js +15 -1
  4. package/src/MainLibs/src/Consts.js +7 -2
  5. package/src/reStructure/GenerateCode.js +16 -18
  6. package/src/reStructure/TemplateData/EndpointPerService/yaml/data.js +1 -1
  7. package/src/reStructure/TemplateData/externalService/functionNameConfig/data.js +18 -8
  8. package/src/reStructure/TemplateData/externalService/lambdaRole/data.js +1 -1
  9. package/src/reStructure/TemplateData/externalService/snsTopicSubscriptions/data.js +15 -15
  10. package/src/reStructure/TemplateData/externalService/snsTopicSubscriptions/template.ejs +2 -2
  11. package/src/reStructure/TemplateData/flowSchema/components/upload/createObject/functionYaml/template.ejs +0 -4
  12. package/src/reStructure/TemplateData/flowSchema/components/upload/createObjectComplete/sns-sqs/data.js +1 -1
  13. package/src/reStructure/TemplateData/flowSchema/components/websocket/connect/functionYaml/data.js +11 -1
  14. package/src/reStructure/TemplateData/flowSchema/components/websocket/connect/functionYaml/template.ejs +1 -14
  15. package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/statusFieldTemplate.ejs +14 -0
  16. package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/storedCacheTemplate.ejs +17 -0
  17. package/src/reStructure/TemplateData/flowSchema/dynamoDb/data.js +81 -0
  18. package/src/reStructure/TemplateData/flowSchema/eventBridge/functionYaml/data.js +202 -0
  19. package/src/reStructure/TemplateData/flowSchema/eventBridge/functionYaml/template.ejs +21 -0
  20. package/src/reStructure/TemplateData/flowSchema/eventBridge/handler/inv/data.js +77 -0
  21. package/src/reStructure/TemplateData/flowSchema/eventBridge/handler/inv/request.json +7 -0
  22. package/src/reStructure/TemplateData/flowSchema/eventBridge/handler/inv/template.ejs +64 -0
  23. package/src/reStructure/TemplateData/flowSchema/eventBridge/mainFunction/data.js +73 -0
  24. package/src/reStructure/TemplateData/flowSchema/eventBridge/mainFunction/request.json +5 -0
  25. package/src/reStructure/TemplateData/flowSchema/eventBridge/mainFunction/template.ejs +88 -0
  26. package/src/reStructure/TemplateData/flowSchema/externalTopic/sqs/handler/data.js +1 -1
  27. package/src/reStructure/TemplateData/flowSchema/externalTopic/sqs/mainFunction/data.js +1 -1
  28. package/src/reStructure/TemplateData/flowSchema/externalTopic/websocket/handler/data.js +1 -1
  29. package/src/reStructure/TemplateData/flowSchema/externalTopic/websocket/mainFunction/data.js +1 -1
  30. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComplete/functionYaml/data.js +89 -0
  31. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComplete/functionYaml/template.ejs +20 -0
  32. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComplete/handler/data.js +57 -0
  33. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComplete/handler/template.ejs +85 -0
  34. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComplete/mainFunction/data.js +55 -0
  35. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComplete/mainFunction/template.ejs +85 -0
  36. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComponent/functionYaml/data.js +3 -28
  37. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComponent/functionYaml/template.ejs +6 -10
  38. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComponent/handler/data.js +4 -2
  39. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComponent/handler/template.ejs +4 -3
  40. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComponent/mainFunction/template.ejs +26 -0
  41. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaCompleteComponent/functionYaml/data.js +2 -2
  42. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaCompleteComponent/functionYaml/template.ejs +6 -10
  43. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaCompleteComponent/handler/data.js +4 -4
  44. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaComponent/functionYaml/template.ejs +0 -4
  45. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaComponent/mainFunction/data.js +8 -1
  46. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaComponent/mainFunction/template.ejs +32 -5
  47. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/sns-in/data.js +18 -18
  48. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/sns-in/sqsTemplate.ejs +53 -0
  49. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/sns-out/data.js +77 -0
  50. package/src/reStructure/TemplateData/flowSchema/generateTemplateData.js +55 -10
  51. package/src/reStructure/TemplateData/generateRole/createSharedResource.js +27 -7
  52. package/src/reStructure/TemplateData/perActionComplete/create/mainFunction/template.ejs +3 -3
  53. package/src/reStructure/TemplateData/perActionComplete/create/yaml/data.js +9 -3
  54. package/src/reStructure/TemplateData/perActionComplete/delete/mainFunction/template.ejs +1 -1
  55. package/src/reStructure/TemplateData/perActionComplete/delete/yaml/data.js +9 -3
  56. package/src/reStructure/TemplateData/perActionComplete/get/mainFunction/template.ejs +1 -1
  57. package/src/reStructure/TemplateData/perActionComplete/get/yaml/data.js +10 -4
  58. package/src/reStructure/TemplateData/perActionComplete/update/mainFunction/template.ejs +1 -1
  59. package/src/reStructure/TemplateData/perActionComplete/update/yaml/data.js +9 -3
  60. package/src/reStructure/TemplateData/relationshipPerAction/create/complete/mainFunction/template.ejs +1 -1
  61. package/src/reStructure/TemplateData/relationshipPerAction/delete/complete/mainFunction/template.ejs +5 -5
  62. package/src/reStructure/TemplateData/relationshipPerAction/get/complete/mainFunction/template.ejs +5 -5
  63. package/src/reStructure/TemplateData/relationshipPerAction/update/complete/mainFunction/template.ejs +1 -1
  64. package/src/reStructure/TemplateData/flowSchema/externalTopic/sqs/handler/template copy.ejs +0 -125
  65. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/sns-in/template.ejs +0 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@izara_project/izara-market-library-service-schemas",
3
- "version": "1.0.32",
3
+ "version": "1.0.34",
4
4
  "description": "Schemas for Izara Market project",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -77,7 +77,8 @@ const TOPIC_NAME_GENERATE_CODE = {
77
77
  outGetNodeComplete: "GetNodeComplete_Out",
78
78
  reservedLimitComplete: "ReservedLimitComplete",
79
79
  createPresignUrl: "CreatePresignUrl",
80
- flowSchemaOwnTopicComplete: "FlowSchemaOwnTopicComplete"
80
+ flowSchemaOwnTopicComplete: "FlowSchemaOwnTopicComplete",
81
+ flowSchemaOwnTopicEndpointComplete: "flowSchemaOwnTopicEndpointComplete",
81
82
  }
82
83
 
83
84
  const GRAPH_HANDLER_SERVICE_NAME = {
@@ -1058,6 +1058,19 @@ function createBasicRelationshipsProperties(from, to, storageResources, baseDire
1058
1058
  return relationshipProperties
1059
1059
  }
1060
1060
 
1061
+ function createFieldNamesFromRequestParamsByObjectSchema(_izContext, requestParams, objectSchema) {
1062
+ let createFieldNameParams = {};
1063
+ _izContext.logger.debug("createFieldNamesFromRequestParamsByObjectSchema ::", { requestParams, objectSchema })
1064
+ for (const fieldName of Object.keys(objectSchema.fieldNames)) {
1065
+ if (Object.keys(requestParams).includes(fieldName)) {
1066
+ if (!createFieldNameParams.hasOwnProperty(fieldName)) {
1067
+ Object.assign(createFieldNameParams, { [fieldName]: requestParams[fieldName] })
1068
+ }
1069
+ }
1070
+ }
1071
+ return createFieldNameParams
1072
+ }
1073
+
1061
1074
  module.exports = {
1062
1075
  sendMsgOutComplete,
1063
1076
  messageToDlq,
@@ -1077,7 +1090,8 @@ module.exports = {
1077
1090
  createDeleteDataDetail,
1078
1091
 
1079
1092
  createFieldForUpdateDynamoDb,
1080
- createBasicRelationshipsProperties
1093
+ createBasicRelationshipsProperties,
1094
+ createFieldNamesFromRequestParamsByObjectSchema
1081
1095
  }
1082
1096
 
1083
1097
 
@@ -120,6 +120,10 @@ const SOURCE_PATH = {
120
120
  resourceLocationWebSocket: "src/generatedCode/FlowSchema/UploadS3/",
121
121
  flowSchemaOwnTopic: "../src/generatedCode/FlowSchema/FlowSchemaOwnTopic/",
122
122
  resourceLocationFlowSchemaOwnTopic: "src/generatedCode/flowSchemaOwnTopic/",
123
+ flowSchemaExternalTopic: "../src/generatedCode/FlowSchema/FlowSchemaExternalTopic/",
124
+ resourceLocationFlowSchemaExternalTopic: "src/generatedCode/flowSchemaExternalTopic/",
125
+ flowSchemaEventBridge: "../src/generatedCode/FlowSchema/EventBridge/",
126
+ resourceLocationFlowSchemaEventBridge: "src/generatedCode/FlowSchema/EventBridge/",
123
127
  generateCodeLib: "../src/generatedCode/libs/source/",
124
128
  logicalFunctionHook: "../src/generatedCode/WebSocket/source/FlowSchemaHook/HookLogicFunction/source/",
125
129
  resourceLocationLogicalFunctionHook: "src/generatedCode/WebSocket/source/FlowSchemaHook/HookLogicFunction/source",
@@ -257,6 +261,7 @@ const FUNCTION_NAME = {
257
261
  flowSchemaOwnTopic: "flowSchemaOwnTopic",
258
262
  flowSchemaOwnTopicComplete: "flowSchemaOwnTopicComplete",
259
263
  flowSchemaOwnTopicEndpoint: "flowSchemaOwnTopicEndpoint",
264
+ flowSchemaOwnTopicEndpointComplete: "flowSchemaOwnTopicEndpointComplete",
260
265
  flowSchemaExternalTopic: "externalTopic",
261
266
  };
262
267
 
@@ -374,9 +379,9 @@ const SOURCE_GENERATE_IAM_ROLE = {
374
379
  RelationshipCompleteRole: "RelationshipCom",
375
380
  FlowSchemaUploadS3Role: "FlowSchemaUploadS3",
376
381
  FlowSchemaOwnTopic: "FlowSchemaOwnTopic",
377
- FlowSchemaOwnTopic: "FlowSchemaOwnTopic",
378
- perActionEndpoint: "PerActionEndpoint",
382
+ PerActionEndpoint: "PerActionEndpoint",
379
383
  ExternalTopicRole: "ExternalTopic",
384
+ EventBridge: "EventBridge",
380
385
  };
381
386
 
382
387
  const ADD_ON_DATA_STRUCTURE_TYPE = {
@@ -45,16 +45,17 @@ async function generateCodeWithTemplate(_izContext, objSchemaPath) {
45
45
  let localServicePath = join(saveFilePath, "../../");
46
46
 
47
47
  // // define path for store yml file
48
- const GENERATE_CODE_SOURCE_PATH = {
49
- appYaml: join(saveFilePath, SOURCE_PATH.appYaml),
50
- resourceYaml: join(saveFilePath, SOURCE_PATH.resourceYaml),
51
- lambdaPerAction: join(saveFilePath, SOURCE_PATH.lambdaPerAction),
52
- externalService: join(saveFilePath, SOURCE_PATH.externalService),
53
- relationshipPerAction: join(saveFilePath, SOURCE_PATH.relationshipPerAction),
54
- webSocketEndpoint: join(saveFilePath, SOURCE_PATH.webSocket),
55
- generateCodeLib: join(saveFilePath, SOURCE_PATH.generateCodeLib),
56
- generatedMainFunctionPerService: join(saveFilePath, SOURCE_PATH.endpointPerService),
57
- };
48
+ // const GENERATE_CODE_SOURCE_PATH = {
49
+ // appYaml: join(saveFilePath, SOURCE_PATH.appYaml),
50
+ // resourceYaml: join(saveFilePath, SOURCE_PATH.resourceYaml),
51
+ // lambdaPerAction: join(saveFilePath, SOURCE_PATH.lambdaPerAction),
52
+ // externalService: join(saveFilePath, SOURCE_PATH.externalService),
53
+ // relationshipPerAction: join(saveFilePath, SOURCE_PATH.relationshipPerAction),
54
+ // webSocketEndpoint: join(saveFilePath, SOURCE_PATH.webSocket),
55
+ // generateCodeLib: join(saveFilePath, SOURCE_PATH.generateCodeLib),
56
+ // generatedMainFunctionPerService: join(saveFilePath, SOURCE_PATH.endpointPerService),
57
+ // flowSchema: join(saveFilePath,'../src/generatedCode/flowSchema')
58
+ // };
58
59
 
59
60
  //------ Start Create Source ------
60
61
 
@@ -108,18 +109,15 @@ async function generateCodeWithTemplate(_izContext, objSchemaPath) {
108
109
  if (status === false) {
109
110
  throw Error(errors)
110
111
  }
111
- }
112
112
 
113
- // validate path before empty folder
114
- for (let folderPathToEmpty of Object.values(GENERATE_CODE_SOURCE_PATH)) {
115
- validatePathWithRootServicePath(localServicePath, folderPathToEmpty)
116
- }
113
+ // console.log("templatePath in generateCode", setting.savePath)
114
+ // empty file by savePath
115
+ // validate path before empty folder
116
+ validatePathWithRootServicePath(localServicePath, setting.savePath)
117
117
 
118
- for (let folderPathToEmpty of Object.values(GENERATE_CODE_SOURCE_PATH)) {
119
- await deleteFileInDir(folderPathToEmpty);
118
+ await deleteFileInDir(setting.savePath);
120
119
  }
121
120
 
122
-
123
121
  // generate all source
124
122
  for (let item of allCreateSource) {
125
123
  // throw error if item is invalid
@@ -66,7 +66,7 @@ async function data(_izContext, allObjSchemas, srcPath) {
66
66
  }
67
67
 
68
68
  async function createParamForCreateSource(_izContext, allObjSchemas, action, handler, srcPath) {
69
- let groupBy = SOURCE_GENERATE_IAM_ROLE.perActionEndpoint;
69
+ let groupBy = SOURCE_GENERATE_IAM_ROLE.PerActionEndpoint;
70
70
  let additionalResourcePermission = defaultIamRolePerAction();
71
71
  let functionNameConfig = upperCase(action) + upperCase(shortNameHandler(handler))
72
72
 
@@ -21,7 +21,7 @@ const path = require('path');
21
21
  const { firstLetterLowerCase: lowerCase, firstLetterUpperCase: upperCase } = require("../../../../MainLibs/index.js").utils;
22
22
  const templateYamlPath = path.join(__dirname, "./templateYaml.ejs");
23
23
  const templatePathIntTestPath = path.join(__dirname, "./templateIntTesting.ejs");
24
- const { SOURCE_PATH, SOURCE_GENERATE_IAM_ROLE } = require("../../../../MainLibs/index.js").consts;
24
+ const { SOURCE_PATH, SOURCE_GENERATE_IAM_ROLE } = require("../../../../MainLibs/src/Consts.js");
25
25
 
26
26
 
27
27
  function data(_izContext, createSourceParams, srcPath) {
@@ -50,13 +50,23 @@ function data(_izContext, createSourceParams, srcPath) {
50
50
  const roleNameConcatConfigs = new Set();
51
51
 
52
52
  // Add default IAM roles from configuration
53
- Object.entries(SOURCE_GENERATE_IAM_ROLE)
54
- .filter(([_, enabled]) => enabled)
55
- .forEach(([_, value]) => {
56
- if (value === SOURCE_GENERATE_IAM_ROLE.NodeCompleteRole) return;
57
- roleNameConfigs.add(`${upperCase(value)}Role`);
58
- roleNameConcatConfigs.add(`${upperCase(value)}`);
59
- });
53
+ // Object.entries(SOURCE_GENERATE_IAM_ROLE)
54
+ // .filter(([_, enabled]) => enabled)
55
+ // .forEach(([_, value]) => {
56
+ // if (value === SOURCE_GENERATE_IAM_ROLE.NodeCompleteRole) return;
57
+ // roleNameConfigs.add(`${upperCase(value)}Role`);
58
+ // roleNameConcatConfigs.add(`${upperCase(value)}`);
59
+ // });
60
+ for (const data of createSourceParams) {
61
+ let roleName = data.templateData?.roleName
62
+ if (roleName) {
63
+ if (roleName === SOURCE_GENERATE_IAM_ROLE.NodeCompleteRole) {
64
+ return
65
+ }
66
+ roleNameConfigs.add(`${upperCase(roleName)}Role`);
67
+ roleNameConcatConfigs.add(`${upperCase(roleName)}`);
68
+ }
69
+ }
60
70
 
61
71
  // Extract role names from templateData in createSourceParams
62
72
  createSourceParams.forEach(({ templateData }) => {
@@ -131,7 +131,7 @@ async function externalLambdaIamRoleDataPerAction(_izContext, allObjSchemas) {
131
131
 
132
132
 
133
133
  return {
134
- objectType: SOURCE_GENERATE_IAM_ROLE.perActionEndpoint,
134
+ objectType: SOURCE_GENERATE_IAM_ROLE.PerActionEndpoint,
135
135
  additionalResourcePermission
136
136
  }
137
137
  }
@@ -99,10 +99,10 @@ const createExternalSnsSubscriptions = async (_izContext, allObjSchemas, allRelS
99
99
 
100
100
  // update Relationship
101
101
  async function snsSubScriptionUpdateRelationshipComplete(_izContext, allRelSchemas) {
102
- let serviceNames = await getGraphServiceNameFromAllRelSchema(_izContext, allRelSchemas)
102
+ let serviceTag = await getGraphServiceNameFromAllRelSchema(_izContext, allRelSchemas)
103
103
 
104
104
  return {
105
- serviceNames: serviceNames,
105
+ serviceTag: serviceTag,
106
106
  topicName: TOPIC_NAME_GRAPH_HANDLER.outUpdateRel, // external service
107
107
  sqsEndpoint: TOPIC_NAME_GENERATE_CODE.updateRelComplete // in service
108
108
  }
@@ -110,10 +110,10 @@ async function snsSubScriptionUpdateRelationshipComplete(_izContext, allRelSchem
110
110
 
111
111
  // create Relationship
112
112
  async function snsSubscriptionCreateRelationshipComplete(_izContext, allRelSchemas) {
113
- let serviceNames = await getGraphServiceNameFromAllRelSchema(_izContext, allRelSchemas)
113
+ let serviceTag = await getGraphServiceNameFromAllRelSchema(_izContext, allRelSchemas)
114
114
 
115
115
  return {
116
- serviceNames: serviceNames,
116
+ serviceTag: serviceTag,
117
117
  topicName: TOPIC_NAME_GRAPH_HANDLER.outCreateRel,
118
118
  sqsEndpoint: TOPIC_NAME_GENERATE_CODE.createRelComplete
119
119
  }
@@ -122,20 +122,20 @@ async function snsSubscriptionCreateRelationshipComplete(_izContext, allRelSchem
122
122
  // topic not create yet will return error when initialSetup
123
123
  // create topic for OutUpdateNodeComplete
124
124
  async function snsSubscriptionOutUpdateNodeComplete(_izContext, allObjSchemas) {
125
- let serviceNames = await getGraphServiceNameFromObjectSchema(_izContext, allObjSchemas)
125
+ let serviceTag = await getGraphServiceNameFromObjectSchema(_izContext, allObjSchemas)
126
126
 
127
127
  return {
128
- serviceNames: serviceNames,
128
+ serviceTag: serviceTag,
129
129
  topicName: TOPIC_NAME_GRAPH_HANDLER.outUpdateNode,
130
130
  sqsEndpoint: TOPIC_NAME_GENERATE_CODE.updateNodeComplete
131
131
  }
132
132
  }
133
133
 
134
134
  async function snsSubscriptionCreateNodeComplete(_izContext, allObjectSchemas) {
135
- let serviceNames = await getGraphServiceNameFromObjectSchema(_izContext, allObjectSchemas)
135
+ let serviceTag = await getGraphServiceNameFromObjectSchema(_izContext, allObjectSchemas)
136
136
 
137
137
  return {
138
- serviceNames: serviceNames,
138
+ serviceTag: serviceTag,
139
139
  topicName: TOPIC_NAME_GRAPH_HANDLER.outCreateNode,
140
140
  sqsEndpoint: TOPIC_NAME_GENERATE_CODE.createNodeComplete
141
141
  }
@@ -152,19 +152,19 @@ async function snsSubscriptionDeleteNodeComplate(_izContext, allObjectSchemas) {
152
152
  }
153
153
 
154
154
  async function snsSubscriptionDeleteRelatipnshipComplete(_izContext, allRelSchemas) {
155
- let serviceNames = await getGraphServiceNameFromAllRelSchema(_izContext, allRelSchemas)
155
+ let serviceTag = await getGraphServiceNameFromAllRelSchema(_izContext, allRelSchemas)
156
156
 
157
157
  return {
158
- serviceNames: serviceNames,
158
+ serviceTag: serviceTag,
159
159
  topicName: TOPIC_NAME_GRAPH_HANDLER.outDeleteRel,
160
160
  sqsEndpoint: TOPIC_NAME_GENERATE_CODE.deleteRelComplete
161
161
  }
162
162
  }
163
163
 
164
164
  function snsSubscriptionReservedLimitCompleteForReservedDynamicUsage(_izContext) {
165
- let serviceNames = [EXTERNAL_SERVICE_NAME.accountLimits]
165
+ let serviceTag = [EXTERNAL_SERVICE_NAME.accountLimits]
166
166
  return {
167
- serviceNames: serviceNames,
167
+ serviceTag: serviceTag,
168
168
  topicName: TOPIC_NAME_EXTERNAL_SERVICE.reservedDynamicUsageComplete,
169
169
  sqsEndpoint: TOPIC_NAME_GENERATE_CODE.createPresignUrl + upperCase(HANDLER.hdrSqs)
170
170
  }
@@ -172,9 +172,9 @@ function snsSubscriptionReservedLimitCompleteForReservedDynamicUsage(_izContext)
172
172
 
173
173
 
174
174
  function snsSubscriptionConfirmReserved(_izContext) {
175
- let serviceNames = [EXTERNAL_SERVICE_NAME.accountLimits];
175
+ let serviceTag = [EXTERNAL_SERVICE_NAME.accountLimits];
176
176
  return {
177
- serviceNames: serviceNames,
177
+ serviceTag: serviceTag,
178
178
  topicName: TOPIC_NAME_EXTERNAL_SERVICE.reservedDynamicUsageComplete,
179
179
  sqsEndpoint: "ConfirmNewReserved" + upperCase(HANDLER.hdrSqs)
180
180
  }
@@ -189,7 +189,7 @@ function snsSubscriptionFlowSchemaExternalTopic(_izContext, localFlowSchema) {
189
189
  const splitFlowStepKey = flowStep.split("_");
190
190
 
191
191
  return {
192
- serviceNames: [splitFlowStepKey[0]],
192
+ serviceTag: [splitFlowStepKey[0]],
193
193
  topicName: splitFlowStepKey[2],
194
194
  sqsEndpoint: splitFlowStepKey[3]
195
195
  };
@@ -18,9 +18,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
18
18
  'use strict';
19
19
 
20
20
  module.exports.generatedSnsTopicSubscription = [ <% datas.forEach(data => { -%>
21
- <% data.serviceNames.forEach(serviceName => { _%>
21
+ <% data.serviceTag.forEach(serviceTag => { _%>
22
22
  {
23
- serviceName: "<%- serviceName %>",
23
+ serviceTag: "<%- serviceTag %>",
24
24
  topicName: "<%- data.topicName %>",
25
25
  sqsEndpoint: "<%- data.sqsEndpoint %>"
26
26
  },
@@ -3,10 +3,6 @@
3
3
  handler: <%- join(resourceLocation, `${firstLetterUpperCase(functionName)}_${firstLetterUpperCase(handlerType)}.main`)%>
4
4
  name: ${self:custom.iz_resourcePrefix}<%- firstLetterUpperCase(functionName) %><%- firstLetterUpperCase(handlerType) %>
5
5
  events:
6
- - websocket:
7
- route: $connect
8
- - websocket:
9
- route: $disconnect
10
6
  - websocket:
11
7
  route: $default
12
8
  - websocket:
@@ -55,7 +55,7 @@ function createDataForDefaultSnsInSqs(_izContext, srcPath) {
55
55
  defaultSnsInSqsDataList.push(
56
56
  {
57
57
  queueName: upperCase(FUNCTION_NAME.createObjectS3Complete) + upperCase(HANDLER.hdrSqs),
58
- subScription: "Out" + upperCase(FUNCTION_NAME.updateNodeComplete)
58
+ subScription: upperCase(FUNCTION_NAME.updateNodeComplete) + "_Out"
59
59
  }
60
60
  )
61
61
 
@@ -52,6 +52,16 @@ function createWebSocketConnectYaml(_izContext, srcPath) {
52
52
  [
53
53
  resourceNames(RESOURCE_CLASSES.dynamoDbTable, "WebSocketTask")
54
54
  ]
55
+ ),
56
+ createIamRole(
57
+ {
58
+ "execute-api": [
59
+ "ManageConnections"
60
+ ]
61
+ },
62
+ [
63
+ resourceNames(RESOURCE_CLASSES.webSocket)
64
+ ]
55
65
  )
56
66
  )
57
67
 
@@ -61,7 +71,7 @@ function createWebSocketConnectYaml(_izContext, srcPath) {
61
71
  functionName,
62
72
  resourceLocation: "src/generatedCode/FlowSchema/WebSocketConnect/source/",
63
73
  additionalResourcePermission,
64
- roleName: SOURCE_GENERATE_IAM_ROLE.FlowSchemaUploadS3Role
74
+ roleName: "WebsocketConnect"
65
75
 
66
76
  },
67
77
  setting: {
@@ -9,20 +9,7 @@
9
9
  route: $disconnect
10
10
  - websocket:
11
11
  route: $default
12
- iamRoleStatements:
13
- <%_ additionalResourcePermission.forEach(resourcePermission => { _%>
14
- - Effect: <%- resourcePermission.effect %>
15
- Action:
16
- <%_ Object.keys(resourcePermission.action).forEach(resourcePerAction => { _%>
17
- <%_ resourcePermission.action[resourcePerAction].forEach(permission => { _%>
18
- - <%- resourcePerAction %>:<%- permission %>
19
- <%_ }) _%>
20
- <%_ }) _%>
21
- Resource:
22
- <%_ resourcePermission.resource.forEach(resource => { _%>
23
- - "<%- resource %>"
24
- <%_ }) _%>
25
- <%_}) _%>
12
+ role: WebsocketConnectRole
26
13
  #<#<WebSocketConnectIamRole#>
27
14
  #<#/<WebSocketConnectIamRole#>
28
15
 
@@ -0,0 +1,14 @@
1
+ // getObjectSchema
2
+ let objectSchema = await getObjectSchema.getObjSchemaS3WithCache(_izContext, flowSchema.objType)
3
+
4
+ // create record
5
+ let fieldNames = createFieldNamesFromRequestParamsByObjectSchema(_izContext, requestParams, objectSchema)
6
+
7
+
8
+ let sendMessageToCreateEndpoint = {
9
+ Message: JSON.stringify({fieldNames: fieldNames}),
10
+ topicArn: await snsSharedLib.snsTopicArnByFlowSchema(_izContext, "Create_In")
11
+ };
12
+
13
+ _izContext.logger.debug("before sendMessageToCreateEndpoint:: ", sendMessageToCreateEndpoint);
14
+ await sns.publishAsync(_izContext, sendMessageToCreateEndpoint);
@@ -0,0 +1,17 @@
1
+ // create storedCache
2
+ function createExpiryTime (_izContext, expiryInterval) {
3
+ const currentTime = new Date();
4
+ const expiryTime = new Date(currentTime);
5
+ expiryTime.setTime(expiryTime.getTime() + expiryInterval);
6
+ return expiryTime.getTime();
7
+ };
8
+
9
+ await dynamodbSharedLib.putItem(_izContext,
10
+ await dynamodbSharedLib.tableName(_izContext, "<%- flowTag %>Main"),
11
+ {
12
+ <%- flowTag %>Id: hash(requestParams),
13
+ cacheExpiryTime: createExpiryTime(_izContext, 31536000000),
14
+ cacheStatus: "processing",
15
+ cacheUniqueRequestId: _izContext.uniqueRequestId
16
+ }
17
+ )
@@ -0,0 +1,81 @@
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
+
20
+ const path = require("path")
21
+
22
+
23
+ // const {
24
+ // HANDLER,
25
+ // STORAGE_TYPES
26
+ // } = require('@izara_project/izara-core-library-service-schemas/src/Consts');
27
+
28
+ const STORAGE_TYPES = {
29
+ dynamoDB: "dynamoDB",
30
+ graph: "graph"
31
+ }
32
+ const templatePath = path.join(__dirname, '../../resourceYaml/dynamodb/template.ejs')
33
+ const { SOURCE_PATH, SAVE_FILE_NAME } = require('../../../../MainLibs/src/Consts.js')
34
+
35
+ /**
36
+ * create param of crateSouce for FindData And processLogical
37
+ *
38
+ * @param {Object} _izContext
39
+ * @param {String} srcPath
40
+ * @returns {Object[]}
41
+ */
42
+ const createAwaitingMultipleStepDynamoDbData = (_izContext, flowSchema, srcPath) => {
43
+
44
+ let resultsForCreateSource = [];
45
+ const defaultDynamoDataLists = [];
46
+
47
+ if (flowSchema.statusType === "storedCache") {
48
+ defaultDynamoDataLists.push(
49
+ {
50
+ tableName: flowSchema.flowTag + "Main",
51
+ resourceName: flowSchema.flowTag + "Main",
52
+ attributes: [
53
+ {
54
+ keyType: "partitionKey",
55
+ AttributeName: flowSchema.flowTag + "Id",
56
+ AttributeType: "S"
57
+ }
58
+ ]
59
+ }
60
+ )
61
+ }
62
+
63
+ for (let defaultDynamoData of defaultDynamoDataLists) {
64
+ resultsForCreateSource.push({
65
+ templatePath: templatePath,
66
+ templateData: defaultDynamoData,
67
+ setting: {
68
+ initialData: 'Resources:\n',
69
+ savePath: path.join(srcPath, SOURCE_PATH.resourceYaml),
70
+ saveFileName: SAVE_FILE_NAME.dynamoDbYaml,
71
+ fileExtension: '.yml',
72
+ isAppend: true
73
+ }
74
+ });
75
+ }
76
+ // console.log("resultsForCreateSource default dynamo", resultsForCreateSource)
77
+
78
+ return resultsForCreateSource;
79
+ }
80
+
81
+ module.exports = createAwaitingMultipleStepDynamoDbData