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

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 (60) hide show
  1. package/package.json +9 -9
  2. package/src/GenerateCodeLibs/src/Consts.js +27 -12
  3. package/src/MainLibs/src/Consts.js +7 -4
  4. package/src/reStructure/TemplateData/EndpointPerService/mainFunction/create/template.ejs +2 -5
  5. package/src/reStructure/TemplateData/EndpointPerService/mainFunction/delete/template.ejs +1 -1
  6. package/src/reStructure/TemplateData/EndpointPerService/mainFunction/update/template.ejs +1 -1
  7. package/src/reStructure/TemplateData/externalService/lambdaRole/data.js +5 -5
  8. package/src/reStructure/TemplateData/externalService/snsTopicSubscriptions/data.js +22 -0
  9. package/src/reStructure/TemplateData/flowSchema/components/upload/confirmReserved/mainFunction/template.ejs +1 -1
  10. package/src/reStructure/TemplateData/flowSchema/components/upload/createObject/handler/template.ejs +1 -1
  11. package/src/reStructure/TemplateData/flowSchema/components/upload/createObjectComplete/mainFunction/template.ejs +1 -1
  12. package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/createPresignUrl/mainFunction/template.ejs +1 -2
  13. package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/reservedLimit/functionYaml/data.js +1 -1
  14. package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/reservedLimit/mainFunction/template.ejs +1 -1
  15. package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/reservedLimit/sqs/template.ejs +18 -18
  16. package/src/reStructure/TemplateData/flowSchema/components/upload/processFile/mainFunction/template.ejs +1 -1
  17. package/src/reStructure/TemplateData/flowSchema/components/upload/relate/libs/data.js +1 -1
  18. package/src/reStructure/TemplateData/flowSchema/externalTopic/sns-in-sqs/data.js +73 -0
  19. package/src/reStructure/TemplateData/flowSchema/externalTopic/sns-in-sqs/template.ejs +53 -0
  20. package/src/reStructure/TemplateData/flowSchema/externalTopic/sns-out/data.js +75 -0
  21. package/src/reStructure/TemplateData/flowSchema/externalTopic/sns-out/template.ejs +10 -0
  22. package/src/reStructure/TemplateData/flowSchema/externalTopic/sqs/functionYaml/data.js +83 -0
  23. package/src/reStructure/TemplateData/flowSchema/externalTopic/sqs/functionYaml/template.ejs +17 -0
  24. package/src/reStructure/TemplateData/flowSchema/externalTopic/sqs/handler/data.js +65 -0
  25. package/src/reStructure/TemplateData/flowSchema/externalTopic/sqs/handler/template copy.ejs +125 -0
  26. package/src/reStructure/TemplateData/flowSchema/externalTopic/sqs/handler/template.ejs +130 -0
  27. package/src/reStructure/TemplateData/flowSchema/externalTopic/sqs/mainFunction/data.js +61 -0
  28. package/src/reStructure/TemplateData/flowSchema/externalTopic/sqs/mainFunction/template.ejs +70 -0
  29. package/src/reStructure/TemplateData/flowSchema/externalTopic/websocket/functionYaml/data.js +147 -0
  30. package/src/reStructure/TemplateData/flowSchema/externalTopic/websocket/functionYaml/template.ejs +18 -0
  31. package/src/reStructure/TemplateData/flowSchema/externalTopic/websocket/handler/data.js +64 -0
  32. package/src/reStructure/TemplateData/flowSchema/{flowSchemaOwnTopic/flowSchema → externalTopic/websocket}/handler/template.ejs +17 -16
  33. package/src/reStructure/TemplateData/flowSchema/externalTopic/websocket/mainFunction/data.js +60 -0
  34. package/src/reStructure/TemplateData/flowSchema/externalTopic/websocket/mainFunction/template.ejs +74 -0
  35. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/{flowSchema → EndpointComponent}/functionYaml/data.js +15 -23
  36. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/{flowSchema → EndpointComponent}/functionYaml/template.ejs +6 -0
  37. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComponent/handler/data.js +57 -0
  38. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComponent/handler/template.ejs +84 -0
  39. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComponent/mainFunction/data.js +52 -0
  40. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComponent/mainFunction/template.ejs +73 -0
  41. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/{flowSchemaComplete → FlowSchemaCompleteComponent}/functionYaml/data.js +25 -23
  42. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/{flowSchemaComplete → FlowSchemaCompleteComponent}/functionYaml/template.ejs +10 -6
  43. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/{flowSchemaComplete → FlowSchemaCompleteComponent}/handler/data.js +6 -20
  44. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaCompleteComponent/handler/template.ejs +84 -0
  45. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/{flowSchemaComplete → FlowSchemaCompleteComponent}/mainFunction/data.js +4 -15
  46. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/{flowSchemaComplete → FlowSchemaCompleteComponent}/mainFunction/template.ejs +16 -33
  47. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaComponent/functionYaml/data.js +117 -0
  48. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaComponent/functionYaml/template.ejs +24 -0
  49. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/{flowSchema → FlowSchemaComponent}/handler/data.js +6 -19
  50. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/{flowSchemaComplete → FlowSchemaComponent}/handler/template.ejs +4 -3
  51. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/{flowSchema → FlowSchemaComponent}/mainFunction/data.js +3 -1
  52. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/sns-in/data.js +96 -0
  53. package/src/reStructure/TemplateData/flowSchema/generateTemplateData.js +163 -115
  54. package/src/reStructure/TemplateData/generateRole/createSharedResource.js +10 -0
  55. package/src/reStructure/TemplateData/relationshipPerAction/create/action/mainFunction/template.ejs +3 -3
  56. package/src/reStructure/TemplateData/relationshipPerAction/delete/action/mainFunction/template.ejs +3 -3
  57. package/src/reStructure/TemplateData/relationshipPerAction/get/action/mainFunction/template.ejs +13 -14
  58. package/src/reStructure/TemplateData/relationshipPerAction/update/action/mainFunction/template.ejs +3 -3
  59. /package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/{flowSchema → FlowSchemaComponent}/mainFunction/template.ejs +0 -0
  60. /package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/{sns-out/data.js → 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.31",
3
+ "version": "1.0.32",
4
4
  "description": "Schemas for Izara Market project",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -20,15 +20,15 @@
20
20
  "testEnvironment": "node"
21
21
  },
22
22
  "dependencies": {
23
+ "@izara_project/izara-core-library-calling-flow": "^1.0.3",
23
24
  "@izara_project/izara-core-library-core": "^1.0.18",
24
- "@izara_project/izara-core-library-external-request": "^1.0.17",
25
- "@izara_project/izara-core-library-service-schemas": "^1.0.48",
26
- "@izara_project/izara-shared": "^1.0.125",
27
- "@izara_project/izara-shared-service-schemas": "^1.0.5",
28
- "@izara_project/izara-core-library-sns": "^1.0.3",
29
- "@izara_project/izara-core-library-sqs": "^1.0.3",
30
- "@izara_project/izara-core-library-calling-flow": "^1.0.2",
31
- "@izara_project/izara-core-library-logger": "^1.0.6",
25
+ "@izara_project/izara-core-library-external-request": "^1.0.18",
26
+ "@izara_project/izara-core-library-logger": "^1.0.7",
27
+ "@izara_project/izara-core-library-service-schemas": "^1.0.49",
28
+ "@izara_project/izara-core-library-sns": "^1.0.4",
29
+ "@izara_project/izara-core-library-sqs": "^1.0.4",
30
+ "@izara_project/izara-shared": "^1.0.126",
31
+ "@izara_project/izara-shared-service-schemas": "^1.0.6",
32
32
  "ejs": "^3.1.10",
33
33
  "js-beautify": "^1.15.4",
34
34
  "lodash": "^4.17.21",
@@ -28,19 +28,34 @@ const PREFIX = {
28
28
  getRel: "getRelationshipEndpoint"
29
29
  }
30
30
 
31
+ // const TOPIC_NAME_GRAPH_HANDLER = {
32
+ // inUpdateRel: "InUpdateRelationship",
33
+ // inCreateRel: "InCreateRelationshipV2",
34
+ // outUpdateRel: "OutUpdateRelationship",
35
+ // outCreateRel: "OutCreateRelationship",
36
+ // inDeleteRel: "InDeleteRelationshipV2",
37
+ // outDeleteRel: "OutDeleteRelationshipV2",
38
+ // inUpdateNode: "InUpdateNode",
39
+ // outUpdateNode: "OutUpdateNode",
40
+ // inCreateNode: "InCreateNodeV2",
41
+ // outCreateNode: "OutCreateNodeV2",
42
+ // inDeleteNode: "InDeleteNodeV2",
43
+ // outDeleteNode: "OutDeleteNodeV2",
44
+ // }
45
+
31
46
  const TOPIC_NAME_GRAPH_HANDLER = {
32
- inUpdateRel: "InUpdateRelationship",
33
- inCreateRel: "InCreateRelationshipV2",
34
- outUpdateRel: "OutUpdateRelationship",
35
- outCreateRel: "OutCreateRelationship",
36
- inDeleteRel: "InDeleteRelationshipV2",
37
- outDeleteRel: "OutDeleteRelationshipV2",
38
- inUpdateNode: "InUpdateNode",
39
- outUpdateNode: "OutUpdateNode",
40
- inCreateNode: "InCreateNodeV2",
41
- outCreateNode: "OutCreateNodeV2",
42
- inDeleteNode: "InDeleteNodeV2",
43
- outDeleteNode: "OutDeleteNodeV2",
47
+ inUpdateRel: "UpdateRelationship_In",
48
+ inCreateRel: "CreateRelationship_In",
49
+ outUpdateRel: "UpdateRelationship_Out",
50
+ outCreateRel: "CreateRelationship_Out",
51
+ inDeleteRel: "DeleteRelationship_In",
52
+ outDeleteRel: "DeleteRelationship_Out",
53
+ inUpdateNode: "UpdateNode_In",
54
+ outUpdateNode: "UpdateNode_Out",
55
+ inCreateNode: "CreateNode_In",
56
+ outCreateNode: "CreateNode_Out",
57
+ inDeleteNode: "DeleteNode_In",
58
+ outDeleteNode: "DeleteNode_Out"
44
59
  }
45
60
 
46
61
  const TOPIC_NAME_GENERATE_CODE = {
@@ -119,7 +119,7 @@ const SOURCE_PATH = {
119
119
  webSocket: "../src/generatedCode/FlowSchema/UploadS3/",
120
120
  resourceLocationWebSocket: "src/generatedCode/FlowSchema/UploadS3/",
121
121
  flowSchemaOwnTopic: "../src/generatedCode/FlowSchema/FlowSchemaOwnTopic/",
122
- resourceLocationFlowSchemaOwnTopic: "src/generatedCode/flowSchemaOwnTopic/UploadS3/",
122
+ resourceLocationFlowSchemaOwnTopic: "src/generatedCode/flowSchemaOwnTopic/",
123
123
  generateCodeLib: "../src/generatedCode/libs/source/",
124
124
  logicalFunctionHook: "../src/generatedCode/WebSocket/source/FlowSchemaHook/HookLogicFunction/source/",
125
125
  resourceLocationLogicalFunctionHook: "src/generatedCode/WebSocket/source/FlowSchemaHook/HookLogicFunction/source",
@@ -190,7 +190,7 @@ function externalResourceName(resourceClass, resourceName, serviceTag) {
190
190
  // [RESOURCE_CLASSES.dynamoDbAcrossService]: "arn:aws:dynamodb:${process.env.iz_region}:${process.env.iz_accountId}:table/*/" + `${resourceName}`,
191
191
  [RESOURCE_CLASSES.dynamoDbAcrossService]: "arn:aws:dynamodb:${process.env.iz_region}:${process.env.iz_accountId}:table/" + `"${serviceTag}"` + `"${resourceName}"`,
192
192
  [RESOURCE_CLASSES.lambda]: "arn:aws:lambda:${process.env.iz_region}:${process.env.iz_accountId}:function:${await lambdaSharedLib.lambdaFunctionName(_izContext, " + `"${resourceName}" ,"${serviceTag}")}`,
193
- [RESOURCE_CLASSES.sns]: "arn:aws:sns:${process.env.iz_region}:${process.env.iz_accountId}:${await snsSharedLib.snsTopicName(_izContext, " + `"${resourceName}", "${serviceTag}")}`
193
+ [RESOURCE_CLASSES.sns]: "arn:aws:sns:${process.env.iz_region}:${process.env.iz_accountId}:${await snsSharedLib.snsTopicNameByFlowSchema(_izContext, " + `"${resourceName}", "${serviceTag}")}`
194
194
 
195
195
  }[resourceClass]
196
196
  };
@@ -255,7 +255,9 @@ const FUNCTION_NAME = {
255
255
  reservedLimit: "reservedLimit",
256
256
  createPresignUrl: "createPresignUrl",
257
257
  flowSchemaOwnTopic: "flowSchemaOwnTopic",
258
- flowSchemaOwnTopicComplete: "flowSchemaOwnTopicComplete"
258
+ flowSchemaOwnTopicComplete: "flowSchemaOwnTopicComplete",
259
+ flowSchemaOwnTopicEndpoint: "flowSchemaOwnTopicEndpoint",
260
+ flowSchemaExternalTopic: "externalTopic",
259
261
  };
260
262
 
261
263
  const SHORT_FUNCTION_NAME = {
@@ -373,7 +375,8 @@ const SOURCE_GENERATE_IAM_ROLE = {
373
375
  FlowSchemaUploadS3Role: "FlowSchemaUploadS3",
374
376
  FlowSchemaOwnTopic: "FlowSchemaOwnTopic",
375
377
  FlowSchemaOwnTopic: "FlowSchemaOwnTopic",
376
- perActionEndpoint: "PerActionEndpoint"
378
+ perActionEndpoint: "PerActionEndpoint",
379
+ ExternalTopicRole: "ExternalTopic",
377
380
  };
378
381
 
379
382
  const ADD_ON_DATA_STRUCTURE_TYPE = {
@@ -205,9 +205,6 @@ module.exports.createMain = async (
205
205
  }
206
206
  })
207
207
  );
208
- if (serviceTag.includes(GRAPH_HANDLER_SERVICE_NAME.graphHandler)) {
209
- filteredRequiredOnCreatedLinks.push(requiredLink);
210
- }
211
208
  })
212
209
  )
213
210
  _izContext.logger.debug("filteredRequiredOnCreatedLinks", filteredRequiredOnCreatedLinks);
@@ -530,7 +527,7 @@ module.exports.createMain = async (
530
527
 
531
528
  let messageToCreateObject = {
532
529
  Message: JSON.stringify(messageObject),
533
- TopicArn: await snsSharedLib.snsTopicArn(_izContext, TOPIC_NAME_GRAPH_HANDLER.inCreateNode, graphServiceName)
530
+ TopicArn: await snsSharedLib.snsTopicArnByFlowSchema(_izContext, TOPIC_NAME_GRAPH_HANDLER.inCreateNode, graphServiceName)
534
531
  };
535
532
  _izContext.logger.debug("RequestParams before send to sqs messageToCreateObject ::::::: ", messageToCreateObject);
536
533
  await sns.publishAsync(_izContext, messageToCreateObject);
@@ -621,4 +618,4 @@ module.exports.createMain = async (
621
618
  } catch (err) {
622
619
  throw (err)
623
620
  }
624
- }
621
+ }
@@ -159,7 +159,7 @@ module.exports.deleteMain = async (
159
159
  let deleteNodeMessageBody = {
160
160
  Message: JSON.stringify(deleteNodeParams),
161
161
  MessageAttributes: sns.createStringMessageAttributes(_izContext, messageAttributes),
162
- TopicArn: await snsSharedLib.snsTopicArn(_izContext, TOPIC_NAME_GRAPH_HANDLER.inDeleteNode, storageTag)
162
+ TopicArn: await snsSharedLib.snsTopicArnByFlowSchema(_izContext, TOPIC_NAME_GRAPH_HANDLER.inDeleteNode, storageTag)
163
163
  }
164
164
 
165
165
  _izContext.logger.debug("request message params before send to IndeleteNode::", deleteNodeMessageBody);
@@ -249,7 +249,7 @@ module.exports.updateMain = async (
249
249
  let updateNodeMessageBody = {
250
250
  Message: JSON.stringify(updateNodeParams),
251
251
  MessageAttributes: sns.createStringMessageAttributes(_izContext, messageAttributes),
252
- TopicArn: await snsSharedLib.snsTopicArn(_izContext, TOPIC_NAME_GRAPH_HANDLER.inUpdateNode, storageTag,)
252
+ TopicArn: await snsSharedLib.snsTopicArnByFlowSchema(_izContext, TOPIC_NAME_GRAPH_HANDLER.inUpdateNode, storageTag,)
253
253
  }
254
254
 
255
255
  _izContext.logger.debug('requset param before send to topic InUpdateNode:::', updateNodeMessageBody);
@@ -115,7 +115,7 @@ async function externalLambdaIamRoleDataPerAction(_izContext, allObjSchemas) {
115
115
  [RESOURCE_CLASSES.sns]: [SNS_RESOURCE.publish]
116
116
  },
117
117
  storageResourceAllLocalObjectSchemas.resourceGraphServiceTag.map(graphServiceName =>
118
- externalResourceName(RESOURCE_CLASSES.sns, "InUpdateNode", graphServiceName)
118
+ externalResourceName(RESOURCE_CLASSES.sns, "UpdateNode_In", graphServiceName)
119
119
  )
120
120
  ),
121
121
  createIamRole(
@@ -123,7 +123,7 @@ async function externalLambdaIamRoleDataPerAction(_izContext, allObjSchemas) {
123
123
  [RESOURCE_CLASSES.sns]: [SNS_RESOURCE.publish]
124
124
  },
125
125
  storageResourceAllLocalObjectSchemas.resourceGraphServiceTag.map(graphServiceName =>
126
- externalResourceName(RESOURCE_CLASSES.sns, "InCreateNodeV2", graphServiceName)
126
+ externalResourceName(RESOURCE_CLASSES.sns, "CreateNode_In", graphServiceName)
127
127
  )
128
128
  )
129
129
  )
@@ -151,7 +151,7 @@ async function externalLamdaIamRoleRelationships(_izContext, allRelSchemas) {
151
151
  [RESOURCE_CLASSES.sns]: [SNS_RESOURCE.publish]
152
152
  },
153
153
  graphServiceNamesFromAllRelSchemas.map(graphServiceName =>
154
- externalResourceName(RESOURCE_CLASSES.sns, "InUpdateRelationship", graphServiceName)
154
+ externalResourceName(RESOURCE_CLASSES.sns, "UpdateRelationship_In", graphServiceName)
155
155
  )
156
156
  ),
157
157
  createIamRole(
@@ -159,7 +159,7 @@ async function externalLamdaIamRoleRelationships(_izContext, allRelSchemas) {
159
159
  [RESOURCE_CLASSES.sns]: [SNS_RESOURCE.publish]
160
160
  },
161
161
  graphServiceNamesFromAllRelSchemas.map(graphServiceName =>
162
- externalResourceName(RESOURCE_CLASSES.sns, "InCreateRelationshipV2", graphServiceName)
162
+ externalResourceName(RESOURCE_CLASSES.sns, "CreateRelationship_In", graphServiceName)
163
163
  )
164
164
  ),
165
165
  createIamRole(
@@ -167,7 +167,7 @@ async function externalLamdaIamRoleRelationships(_izContext, allRelSchemas) {
167
167
  [RESOURCE_CLASSES.sns]: [SNS_RESOURCE.publish]
168
168
  },
169
169
  graphServiceNamesFromAllRelSchemas.map(graphServiceName =>
170
- externalResourceName(RESOURCE_CLASSES.sns, "InDeleteRelationshipV2", graphServiceName)
170
+ externalResourceName(RESOURCE_CLASSES.sns, "DeleteRelationship_In", graphServiceName)
171
171
  )
172
172
  ),
173
173
  createIamRole(
@@ -75,6 +75,10 @@ const createExternalSnsSubscriptions = async (_izContext, allObjSchemas, allRelS
75
75
  const snsServiceConfigForConfirmReserved = await snsSubscriptionConfirmReserved(_izContext);
76
76
  snsServiceConfigForConfirmReserved && snsServiceConfigArray.push(snsServiceConfigForConfirmReserved);
77
77
  }
78
+ if (event.includes("extTopic")) {
79
+ const snsServiceConfigForExtTopic = await snsSubscriptionFlowSchemaExternalTopic(_izContext, localFlowSchema);
80
+ snsServiceConfigForExtTopic && snsServiceConfigArray.push(snsServiceConfigForExtTopic);
81
+ }
78
82
  }
79
83
  }
80
84
  }
@@ -176,4 +180,22 @@ function snsSubscriptionConfirmReserved(_izContext) {
176
180
  }
177
181
  }
178
182
 
183
+ function snsSubscriptionFlowSchemaExternalTopic(_izContext, localFlowSchema) {
184
+ const flowSteps = Object.keys(localFlowSchema.flowSteps || {});
185
+ const lastIndex = flowSteps.length - 1;
186
+
187
+ if (lastIndex >= 0) {
188
+ const flowStep = flowSteps[lastIndex];
189
+ const splitFlowStepKey = flowStep.split("_");
190
+
191
+ return {
192
+ serviceNames: [splitFlowStepKey[0]],
193
+ topicName: splitFlowStepKey[2],
194
+ sqsEndpoint: splitFlowStepKey[3]
195
+ };
196
+ }
197
+
198
+ return null;
199
+ }
200
+
179
201
  module.exports = createExternalSnsSubscriptions;
@@ -21,7 +21,7 @@ const dynamodbSharedLib = require('@izara_project/izara-core-library-dynamodb')
21
21
  const snsSharedLib = require('@izara_project/izara-core-library-sns')
22
22
  const sns = require('@izara_project/izara-core-library-external-request').sns
23
23
  const consts = require('@izara_project/izara-market-library-service-schemas/src/GenerateCodeLibs/src/Consts')
24
- const { getNestObject } = require('../../libs/source/ImportDataLib')
24
+ const { getNestObject } = require('../../libs/source/GenerateCodeLibs')
25
25
  /**
26
26
  * description of function.
27
27
  * @param {Object} _izContext
@@ -26,7 +26,7 @@ const callingFlowSharedLib = require('@izara_project/izara-core-library-calling-
26
26
  const hash = require('object-hash')
27
27
  // const coreConsts = require("@izara_project/izara-core-library-core/src/Consts");
28
28
  const consts = require('@izara_project/izara-middleware/src/MiddlewareCore/Consts')
29
- const { postToConnection } = require("../../libs/source/ImportDataLib");
29
+ const { postToConnection } = require("../../libs/source/GenerateCodeLibs");
30
30
  const createObject = require('./CreateObjectS3_Main');
31
31
  module.exports.main = middleware.wrap(async (event, context, callback) => {
32
32
 
@@ -21,7 +21,7 @@ const snsSharedLib = require('@izara_project/izara-core-library-sns');
21
21
  const asyncFlowSharedLib = require('@izara_project/izara-core-library-asynchronous-flow');
22
22
  let coreConsts = require('@izara_project/izara-middleware/src/MiddlewareCore/Consts')
23
23
 
24
- const { postToConnection } = require('../../libs/source/ImportDataLib')
24
+ const { postToConnection } = require('../../libs/source/GenerateCodeLibs')
25
25
  module.exports.webSocketTaskComplete = async (
26
26
  _izContext,
27
27
  objType,
@@ -32,11 +32,10 @@ const client = new S3Client({ region: 'us-east-2' });
32
32
  const { createPresignedPost } = require('@aws-sdk/s3-presigned-post');
33
33
  const consts = require('@izara_project/izara-middleware/src/MiddlewareCore/Consts')
34
34
 
35
- const { postToConnection } = require("../../libs/source/ImportDataLib");
35
+ const { postToConnection,getNestObject } = require("../../libs/source/GenerateCodeLibs");
36
36
  const hash = require('object-hash');
37
37
  const utils = require('@izara_project/izara-market-library-service-schemas/src/MainLibs/src/Utils');
38
38
  const coreConsts = require('@izara_project/izara-core-library-core/src/Consts');
39
- const { getNestObject } = require("../../libs/source/ImportDataLib");
40
39
  const { EXTERNAL_SERVICE_NAME } = require('@izara_project/izara-market-library-service-schemas/src/GenerateCodeLibs/src/Consts');
41
40
  /**
42
41
  * description of function.
@@ -88,7 +88,7 @@ function createSourceParams(_izContext, flowSchema, srcPath) {
88
88
  functionName,
89
89
  handlerType,
90
90
  functionNameConfig: functionName + upperCase(handlerType),
91
- resourceLocation: path.join(SOURCE_PATH.resourceLocationWebSocket, flowSchema.flowTag, "source/"),
91
+ resourceLocation: path.join(SOURCE_PATH.resourceLocationWebSocket, flowSchema.flowTag, "/source/"),
92
92
  additionalResourcePermission,
93
93
  functionNameConfig: upperCase(functionName) + upperCase(shortNameHandler(handlerType)),
94
94
  roleName: SOURCE_GENERATE_IAM_ROLE.FlowSchemaUploadS3Role
@@ -27,7 +27,7 @@ const lambda = externalRequest.lambda
27
27
  const consts = require('@izara_project/izara-market-library-service-schemas/src/GenerateCodeLibs/src/Consts')
28
28
  const coreConsts = require('@izara_project/izara-middleware/src/MiddlewareCore/Consts')
29
29
  const hash = require('object-hash');
30
- const importDataLibs = require('../../libs/source/ImportDataLib')
30
+ const importDataLibs = require('../../libs/source/GenerateCodeLibs')
31
31
  /**
32
32
  * description of function.
33
33
  * @param {Object} _izContext
@@ -1,31 +1,30 @@
1
1
  ##===== SNS Subscription
2
- ##===== [Topic In]
3
- Subscription<%- queueName %>:
2
+ SubscriptionOut<%- queueNameSubscription %>:
4
3
  Type: AWS::SNS::Subscription
5
4
  Properties:
6
- TopicArn: !Ref <%- subscription %>
7
- Endpoint: "arn:aws:sqs:${self:custom.iz_region}:${self:custom.iz_accountId}:${self:custom.iz_resourcePrefix}<%- queueName %>HdrSqs"
5
+ TopicArn: !Ref Out<%- queueNameSubscription %>
6
+ Endpoint: "arn:aws:sqs:${self:custom.iz_region}:${self:custom.iz_accountId}:${self:custom.iz_resourcePrefix}<%- queueNameSubscription %>Out"
8
7
  Protocol: "sqs"
9
8
  ##===== [Queue]
10
- <%- queueName %>HdrSqs:
9
+ <%- queueName %>:
11
10
  Type: "AWS::SQS::Queue"
12
11
  Properties:
13
- QueueName: ${self:custom.iz_resourcePrefix}<%- queueName %>HdrSqs
12
+ QueueName: ${self:custom.iz_resourcePrefix}<%- queueName %>
14
13
  RedrivePolicy:
15
14
  deadLetterTargetArn:
16
15
  # !GetAtt
17
16
  Fn::GetAtt:
18
- - <%- queueName %>HdrSqsDLQ
17
+ - <%- queueName %>DLQ
19
18
  - Arn
20
19
  maxReceiveCount: 3
21
20
  VisibilityTimeout: 120
22
21
  ##==== [QueueDLQ]
23
- <%- queueName %>HdrSqsDLQ:
22
+ <%- queueName %>DLQ:
24
23
  Type: AWS::SQS::Queue
25
24
  Properties:
26
- QueueName: ${self:custom.iz_resourcePrefix}<%- queueName %>HdrSqsDLQ
25
+ QueueName: ${self:custom.iz_resourcePrefix}<%- queueName %>DLQ
27
26
  ##==== [QueuePolicy]
28
- <%- queueName %>HdrSqsPolicy:
27
+ <%- queueName %>Policy:
29
28
  Type: AWS::SQS::QueuePolicy
30
29
  Properties:
31
30
  PolicyDocument:
@@ -37,17 +36,18 @@
37
36
  Resource:
38
37
  # !GetAtt
39
38
  Fn::GetAtt:
40
- - <%- queueName %>HdrSqs
39
+ - <%- queueName %>
41
40
  - Arn
42
41
  Action: "SQS:SendMessage"
43
42
  Queues:
44
- - Ref: <%- queueName %>HdrSqs
43
+ - Ref: <%- queueName %>
45
44
  #<#<%- firstLetterUpperCase(queueName) %>QueueSetting#>
46
45
  #<#/<%- firstLetterUpperCase(queueName) %>QueueSetting#>
47
46
 
48
- <%_ function firstLetterUpperCase(text){
49
- return text.charAt(0).toUpperCase() + text.slice(1)
50
- } _%>
51
- <%_ function firstLetterLowerCase(str) {
52
- return str.charAt(0).toLowerCase() + str.slice(1)
53
- } _%>
47
+
48
+ <%_ function firstLetterUpperCase(text){
49
+ return text.charAt(0).toUpperCase() + text.slice(1)
50
+ } _%>
51
+ <%_ function firstLetterLowerCase(str) {
52
+ return str.charAt(0).toLowerCase() + str.slice(1)
53
+ } _%>
@@ -33,7 +33,7 @@ const s3 = new S3Client({ region: 'us-east-2' });
33
33
 
34
34
  const hash = require('object-hash');
35
35
  const Readable = require('stream');
36
- const { isValidCsv, getNestObject } = require('../../libs/source/ImportDataLib')
36
+ const { isValidCsv, getNestObject } = require('../../libs/source/GenerateCodeLibs')
37
37
  const consts = require('@izara_project/izara-market-library-service-schemas/src/GenerateCodeLibs/src/Consts')
38
38
  const coreConsts = require('@izara_project/izara-core-library-core/src/Consts');
39
39
 
@@ -31,7 +31,7 @@ function createSourceParams(_izContext, srcPath) {
31
31
  templatePath: templatePath,
32
32
  templateData: {},
33
33
  setting: {
34
- saveFileName: "ImportDataLib",
34
+ saveFileName: "GenerateCodeLibs",
35
35
  savePath: path.join(srcPath, SOURCE_PATH.generateCodeLib),
36
36
  fileExtension: ".js",
37
37
  isAppend: false
@@ -0,0 +1,73 @@
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
+ const templatePath = path.join(__dirname, './template.ejs');
23
+
24
+ const {
25
+ firstLetterLowerCase: lowerCase,
26
+ firstLetterUpperCase: upperCase,
27
+ firstLetterUpperCase,
28
+ } = require("../../../../../MainLibs/src/Utils");
29
+ const {
30
+ DEFAULT_HANDLER_PER_ACTION,
31
+ SOURCE_PATH,
32
+ FUNCTION_NAME,
33
+ SAVE_FILE_NAME,
34
+ SOURCE_GENERATE_IAM_ROLE,
35
+ } = require("../../../../../MainLibs/src/Consts");
36
+
37
+ /**
38
+ * create data for dynamoDbYaml tempalte from objectSchema
39
+ * return array of dynamoDb data
40
+ * because one objectSchema can create multiple dynamoDb table
41
+ *
42
+ * @param {Object} _izContext
43
+ * @param {String} saveFilePath
44
+ * @returns {Object[]} - data of multiple dynamoDb template
45
+ */
46
+
47
+ function data(_izContext, flowSchema, srcPath) {
48
+ const flowStepSplitKey = Object.keys(flowSchema.flowSteps)[0].split("_");
49
+ let queueName;
50
+ let queueNameSubscription;
51
+ if (Object.keys(flowSchema.flowSteps).length > 3) {
52
+ queueName = flowStepSplitKey[3] + 'Out';
53
+ queueNameSubscription = flowStepSplitKey[3]
54
+ }
55
+
56
+ return [{
57
+ templatePath,
58
+ templateData: {
59
+ queueName: upperCase(queueName),
60
+ queueNameSubscription: upperCase(queueNameSubscription),
61
+ roleName: SOURCE_GENERATE_IAM_ROLE.ExternalTopicRole,
62
+ },
63
+ setting: {
64
+ initialData: "Resource\n",
65
+ savePath: path.join(srcPath, SOURCE_PATH.resourceYaml),
66
+ saveFileName: SAVE_FILE_NAME.snsInSqsYaml,
67
+ fileExtension: ".yml",
68
+ isAppend: true
69
+ }
70
+ }]
71
+ }
72
+
73
+ module.exports = data
@@ -0,0 +1,53 @@
1
+ ##===== SNS Subscription
2
+ SubscriptionOut<%- queueNameSubscription %>:
3
+ Type: AWS::SNS::Subscription
4
+ Properties:
5
+ TopicArn: !Ref Out<%- queueNameSubscription %>
6
+ Endpoint: "arn:aws:sqs:${self:custom.iz_region}:${self:custom.iz_accountId}:${self:custom.iz_resourcePrefix}<%- queueNameSubscription %>Out"
7
+ Protocol: "sqs"
8
+ ##===== [Queue]
9
+ <%- queueName %>:
10
+ Type: "AWS::SQS::Queue"
11
+ Properties:
12
+ QueueName: ${self:custom.iz_resourcePrefix}<%- queueName %>
13
+ RedrivePolicy:
14
+ deadLetterTargetArn:
15
+ # !GetAtt
16
+ Fn::GetAtt:
17
+ - <%- queueName %>DLQ
18
+ - Arn
19
+ maxReceiveCount: 3
20
+ VisibilityTimeout: 120
21
+ ##==== [QueueDLQ]
22
+ <%- queueName %>DLQ:
23
+ Type: AWS::SQS::Queue
24
+ Properties:
25
+ QueueName: ${self:custom.iz_resourcePrefix}<%- queueName %>DLQ
26
+ ##==== [QueuePolicy]
27
+ <%- queueName %>Policy:
28
+ Type: AWS::SQS::QueuePolicy
29
+ Properties:
30
+ PolicyDocument:
31
+ Version: "2012-10-17"
32
+ Statement:
33
+ - Sid: "allow-sns-messages"
34
+ Effect: Allow
35
+ Principal: "*"
36
+ Resource:
37
+ # !GetAtt
38
+ Fn::GetAtt:
39
+ - <%- queueName %>
40
+ - Arn
41
+ Action: "SQS:SendMessage"
42
+ Queues:
43
+ - Ref: <%- queueName %>
44
+ #<#<%- firstLetterUpperCase(queueName) %>QueueSetting#>
45
+ #<#/<%- firstLetterUpperCase(queueName) %>QueueSetting#>
46
+
47
+
48
+ <%_ function firstLetterUpperCase(text){
49
+ return text.charAt(0).toUpperCase() + text.slice(1)
50
+ } _%>
51
+ <%_ function firstLetterLowerCase(str) {
52
+ return str.charAt(0).toLowerCase() + str.slice(1)
53
+ } _%>
@@ -0,0 +1,75 @@
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
+ // const { ACTIONS, HANDLER } = require('@izara_project/izara-core-library-service-schemas/src/Consts');
23
+
24
+ const {
25
+ firstLetterLowerCase: lowerCase,
26
+ firstLetterUpperCase: upperCase,
27
+ } = require("../../../../../MainLibs/src/Utils");
28
+ const {
29
+ DEFAULT_HANDLER_PER_ACTION,
30
+ SOURCE_PATH,
31
+ SAVE_FILE_NAME,
32
+ FUNCTION_NAME,
33
+ SOURCE_GENERATE_IAM_ROLE
34
+ } = require("../../../../../MainLibs/src/Consts");
35
+
36
+ const templatePath = path.join(__dirname, "../../../../TemplateData/resourceYaml/sns-out/template.ejs");
37
+ // /ResourceYaml/sns-out/template.ejs
38
+ // /OutPerActionComplete/OutUpdateComplete/sns-out/data.js
39
+
40
+ /**
41
+ * create data for dynamoDbYaml tempalte from objectSchema
42
+ * return array of dynamoDb data
43
+ * because one objectSchema can create multiple dynamoDb table
44
+ *
45
+ * @param {Object} _izContext
46
+ * @param {String} saveFilePath
47
+ * @returns {Object[]} - data of multiple dynamoDb template
48
+ */
49
+ function data(_izContext, flowSchema, srcPath) {
50
+ const createSourceParams = createParamsForCreateSource(_izContext, flowSchema, srcPath)
51
+ return createSourceParams
52
+ }
53
+
54
+ function createParamsForCreateSource(_izContext, flowSchema, srcPath) {
55
+ const flowStepSplitKey = Object.keys(flowSchema.flowSteps)[1].split('_');
56
+ const queueName = flowStepSplitKey[3]
57
+ return [
58
+ {
59
+ templatePath: templatePath,
60
+ templateData: {
61
+ queueName: upperCase(queueName),
62
+ roleName: SOURCE_GENERATE_IAM_ROLE.ExternalTopicRole,
63
+ },
64
+ setting: {
65
+ initialData: 'Resources:\n',
66
+ savePath: path.join(srcPath, SOURCE_PATH.resourceYaml),
67
+ saveFileName: SAVE_FILE_NAME.snsOutYaml,
68
+ fileExtension: '.yml',
69
+ isAppend: true
70
+ }
71
+ }
72
+ ]
73
+ }
74
+
75
+ module.exports = data
@@ -0,0 +1,10 @@
1
+ ##--------- [Create Topic Out]
2
+ Out<%- firstLetterUpperCase(queueName) %>:
3
+ Type: AWS::SNS::Topic
4
+ Properties:
5
+ DisplayName: "SNS Message out"
6
+ TopicName: ${self:custom.iz_serviceTag}_${self:custom.iz_stage}_<%- firstLetterUpperCase(queueName) %>_Out
7
+
8
+ <%_ function firstLetterUpperCase(text) {
9
+ return text.charAt(0).toUpperCase() + text.slice(1)
10
+ } _%>