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

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 (135) hide show
  1. package/package.json +1 -1
  2. package/src/GenerateCodeLibs/src/Consts.js +2 -1
  3. package/src/GenerateCodeLibs/src/GenerateCodeLibs.js +7 -6
  4. package/src/MainLibs/src/Consts.js +47 -14
  5. package/src/MainLibs/src/GenerateCodeUtils.js +2 -0
  6. package/src/TemplateManager/src/attributeTree/relationshipSchema/data.js +1 -1
  7. package/src/TemplateManager/src/attributeTreeSchema/generateTemplateData.js +103 -0
  8. package/src/{reStructure/TemplateData/attributeTreeSchema/mainAttributeTreeSchema → TemplateManager/src/attributeTreeSchema/mainAttributeTree}/attributeLinkTemplate.ejs +3 -7
  9. package/src/TemplateManager/src/attributeTreeSchema/mainAttributeTree/data.js +134 -0
  10. package/src/TemplateManager/src/attributeTreeSchema/referenceRelationshipSchema/data.js +84 -0
  11. package/src/TemplateManager/src/attributeTreeSchema/referenceRelationshipSchema/tempReferenceRelationshipSchema.ejs +9 -0
  12. package/src/TemplateManager/src/attributeTreeSchema/relationshipSchema/data.js +172 -0
  13. package/src/TemplateManager/src/attributeTreeSchema/relationshipSchema/template.ejs +7 -0
  14. package/src/reStructure/GenerateCode.js +1 -0
  15. package/src/reStructure/SchemaConfig.js +1 -3
  16. package/src/reStructure/TemplateData/EndpointPerService/handler/api/template.ejs +2 -2
  17. package/src/reStructure/TemplateData/EndpointPerService/handler/inv/template.ejs +2 -2
  18. package/src/reStructure/TemplateData/EndpointPerService/mainFunction/create/backupTemplate.ejs +701 -0
  19. package/src/reStructure/TemplateData/EndpointPerService/mainFunction/create/template.ejs +34 -159
  20. package/src/reStructure/TemplateData/EndpointPerService/mainFunction/delete/template.ejs +2 -0
  21. package/src/reStructure/TemplateData/EndpointPerService/mainFunction/get/template.ejs +3 -4
  22. package/src/reStructure/TemplateData/EndpointPerService/mainFunction/update/template.ejs +2 -0
  23. package/src/reStructure/TemplateData/externalService/lambdaRole/data.js +38 -12
  24. package/src/reStructure/TemplateData/externalService/lambdaRole/template.ejs +5 -2
  25. package/src/reStructure/TemplateData/externalService/snsTopicSubscriptions/data.js +22 -14
  26. package/src/reStructure/TemplateData/externalService/snsTopicSubscriptions/template.ejs +4 -1
  27. package/src/reStructure/TemplateData/flowSchema/CreateRecordComplete/functionYaml/data.js +123 -0
  28. package/src/reStructure/TemplateData/flowSchema/CreateRecordComplete/functionYaml/template.ejs +20 -0
  29. package/src/reStructure/TemplateData/flowSchema/CreateRecordComplete/handler/data.js +57 -0
  30. package/src/reStructure/TemplateData/flowSchema/CreateRecordComplete/handler/template.ejs +85 -0
  31. package/src/reStructure/TemplateData/flowSchema/CreateRecordComplete/mainFunction/data.js +68 -0
  32. package/src/reStructure/TemplateData/flowSchema/CreateRecordComplete/mainFunction/template.ejs +131 -0
  33. package/src/reStructure/TemplateData/flowSchema/CreateRecordComplete/queue/data.js +77 -0
  34. package/src/reStructure/TemplateData/flowSchema/CreateRecordComplete/queue/template.ejs +49 -0
  35. package/src/reStructure/TemplateData/flowSchema/components/upload/createObject/handler/template.ejs +1 -1
  36. package/src/reStructure/TemplateData/flowSchema/components/upload/createObjectComplete/mainFunction/template.ejs +1 -1
  37. package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/createPresignUrl/mainFunction/template.ejs +1 -1
  38. package/src/reStructure/TemplateData/flowSchema/components/upload/relate/libs/data.js +12 -4
  39. package/src/reStructure/TemplateData/flowSchema/components/upload/relate/libs/template.ejs +13 -8
  40. package/src/reStructure/TemplateData/flowSchema/components/websocket/connect/handler/template.ejs +4 -4
  41. package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/complete/functionYaml/data.js +141 -0
  42. package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/complete/functionYaml/template.ejs +20 -0
  43. package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/complete/handler/data.js +55 -0
  44. package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/complete/handler/template.ejs +83 -0
  45. package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/complete/mainFunction/data.js +55 -0
  46. package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/complete/mainFunction/template.ejs +131 -0
  47. package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/dynamoDB/register.js +82 -0
  48. package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/sns-in/data.js +64 -0
  49. package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/sns-in/template.ejs +45 -0
  50. package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/statusFieldTemplate.ejs +19 -6
  51. package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/storedCacheTemplate.ejs +9 -15
  52. package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/subscriptionOutAll/data.js +76 -0
  53. package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/subscriptionOutAll/template.ejs +13 -0
  54. package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/wbs/functionYaml/data.js +164 -0
  55. package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/wbs/functionYaml/template.ejs +18 -0
  56. package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/wbs/handler/data.js +64 -0
  57. package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/wbs/handler/template.ejs +88 -0
  58. package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/wbs/mainFunction/data.js +55 -0
  59. package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/wbs/mainFunction/template.ejs +222 -0
  60. package/src/reStructure/TemplateData/flowSchema/dynamoDb/data.js +83 -44
  61. package/src/reStructure/TemplateData/flowSchema/eventBridge/functionYaml/data.js +26 -59
  62. package/src/reStructure/TemplateData/flowSchema/eventBridge/functionYaml/template.ejs +3 -3
  63. package/src/reStructure/TemplateData/flowSchema/eventBridge/handler/inv/data.js +8 -8
  64. package/src/reStructure/TemplateData/flowSchema/eventBridge/mainFunction/data.js +11 -9
  65. package/src/reStructure/TemplateData/flowSchema/eventBridge/mainFunction/template.ejs +3 -3
  66. package/src/reStructure/TemplateData/flowSchema/externalTopic/sns-in-sqs/data.js +5 -9
  67. package/src/reStructure/TemplateData/flowSchema/externalTopic/sns-in-sqs/template.ejs +1 -7
  68. package/src/reStructure/TemplateData/flowSchema/externalTopic/sns-out/data.js +2 -3
  69. package/src/reStructure/TemplateData/flowSchema/externalTopic/sns-out/template.ejs +2 -4
  70. package/src/reStructure/TemplateData/flowSchema/externalTopic/sqs/functionYaml/data.js +37 -11
  71. package/src/reStructure/TemplateData/flowSchema/externalTopic/sqs/functionYaml/template.ejs +4 -4
  72. package/src/reStructure/TemplateData/flowSchema/externalTopic/sqs/handler/data.js +8 -9
  73. package/src/reStructure/TemplateData/flowSchema/externalTopic/sqs/handler/template.ejs +13 -13
  74. package/src/reStructure/TemplateData/flowSchema/externalTopic/sqs/mainFunction/data.js +4 -4
  75. package/src/reStructure/TemplateData/flowSchema/externalTopic/sqs/mainFunction/template.ejs +44 -69
  76. package/src/reStructure/TemplateData/flowSchema/externalTopic/websocket/functionYaml/data.js +7 -44
  77. package/src/reStructure/TemplateData/flowSchema/externalTopic/websocket/functionYaml/template.ejs +3 -3
  78. package/src/reStructure/TemplateData/flowSchema/externalTopic/websocket/handler/data.js +3 -10
  79. package/src/reStructure/TemplateData/flowSchema/externalTopic/websocket/handler/template.ejs +40 -86
  80. package/src/reStructure/TemplateData/flowSchema/externalTopic/websocket/mainFunction/data.js +11 -4
  81. package/src/reStructure/TemplateData/flowSchema/externalTopic/websocket/mainFunction/template.ejs +11 -8
  82. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComplete/functionYaml/data.js +17 -3
  83. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComplete/functionYaml/template.ejs +2 -2
  84. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComplete/mainFunction/data.js +8 -2
  85. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComplete/mainFunction/template.ejs +49 -84
  86. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComponent/functionYaml/data.js +55 -10
  87. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComponent/functionYaml/template.ejs +1 -1
  88. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComponent/handler/data.js +2 -2
  89. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComponent/handler/template.ejs +1 -1
  90. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComponent/mainFunction/data.js +27 -8
  91. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComponent/mainFunction/template.ejs +50 -20
  92. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaCompleteComponent/functionYaml/data.js +20 -5
  93. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaCompleteComponent/functionYaml/template.ejs +1 -1
  94. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaCompleteComponent/handler/data.js +2 -2
  95. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaCompleteComponent/handler/template.ejs +5 -5
  96. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaCompleteComponent/mainFunction/data.js +5 -3
  97. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaCompleteComponent/mainFunction/template.ejs +7 -5
  98. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaComponent/functionYaml/data.js +6 -3
  99. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaComponent/functionYaml/template.ejs +0 -2
  100. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaComponent/handler/data.js +2 -2
  101. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaComponent/handler/template.ejs +3 -3
  102. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaComponent/mainFunction/data.js +9 -9
  103. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaComponent/mainFunction/template.ejs +17 -39
  104. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/sns-in/data.js +14 -8
  105. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/sns-out/data.js +4 -1
  106. package/src/reStructure/TemplateData/flowSchema/generateTemplateData.js +90 -21
  107. package/src/reStructure/TemplateData/generateRole/createSharedResource.js +22 -1
  108. package/src/reStructure/TemplateData/generateRole/sharedResourceTemplate.ejs +3 -0
  109. package/src/reStructure/TemplateData/perActionComplete/create/mainFunction/template.ejs +9 -8
  110. package/src/reStructure/TemplateData/perActionComplete/delete/mainFunction/template.ejs +5 -1
  111. package/src/reStructure/TemplateData/perActionComplete/get/mainFunction/template.ejs +2 -1
  112. package/src/reStructure/TemplateData/processLogical/mainFunction/template.ejs +1 -0
  113. package/src/reStructure/TemplateData/propertyValueSchema/generateTemplateData.js +66 -0
  114. package/src/reStructure/TemplateData/propertyValueSchema/objectPropertyValueSchema/data.js +131 -0
  115. package/src/reStructure/TemplateData/propertyValueSchema/objectPropertyValueSchema/templateObjectPropertyValueSchema.ejs +16 -0
  116. package/src/reStructure/TemplateData/propertyValueSchema/relationshipPropertyValueSchema/data.js +156 -0
  117. package/src/reStructure/TemplateData/propertyValueSchema/relationshipPropertyValueSchema/tempRelationship.ejs +13 -0
  118. package/src/reStructure/TemplateData/propertyValueSchema/relationshipPropertyValueSchema/templateRelationshipPropertyValueSchema.ejs +7 -0
  119. package/src/reStructure/TemplateData/relationshipPerAction/create/action/mainFunction/template.ejs +2 -1
  120. package/src/reStructure/TemplateData/relationshipPerAction/create/complete/mainFunction/template.ejs +2 -1
  121. package/src/reStructure/TemplateData/relationshipPerAction/delete/action/mainFunction/template.ejs +2 -1
  122. package/src/reStructure/TemplateData/relationshipPerAction/delete/complete/handler/sqs/template.ejs +5 -5
  123. package/src/reStructure/TemplateData/relationshipPerAction/delete/complete/mainFunction/template.ejs +5 -4
  124. package/src/reStructure/TemplateData/relationshipPerAction/get/action/mainFunction/template.ejs +2 -1
  125. package/src/reStructure/TemplateData/relationshipPerAction/get/complete/handler/sqs/template.ejs +4 -4
  126. package/src/reStructure/TemplateData/relationshipPerAction/get/complete/mainFunction/template.ejs +4 -3
  127. package/src/reStructure/TemplateData/relationshipPerAction/update/action/mainFunction/template.ejs +2 -1
  128. package/src/reStructure/TemplateData/relationshipPerAction/update/complete/mainFunction/template.ejs +2 -1
  129. package/src/reStructure/TemplateData/resourceYaml/dynamodb/template.ejs +1 -3
  130. package/src/reStructure/TemplateData/resourceYaml/filterGenerateResource/data.js +61 -0
  131. package/src/reStructure/TemplateData/resourceYaml/generateTemplateData.js +13 -4
  132. package/src/reStructure/libs/ValidateAddOnDataStructure.js +62 -0
  133. package/src/reStructure/TemplateData/attributeTreeSchema/generateTemplateData.js +0 -104
  134. package/src/reStructure/TemplateData/attributeTreeSchema/mainAttributeTreeSchema/data.js +0 -188
  135. /package/src/{reStructure/TemplateData/attributeTreeSchema/mainAttributeTreeSchema → TemplateManager/src/attributeTreeSchema/mainAttributeTree}/request.json +0 -0
@@ -33,7 +33,8 @@ const {
33
33
  FUNCTION_NAME,
34
34
  shortNameHandler,
35
35
  externalResourceYaml,
36
- SOURCE_GENERATE_IAM_ROLE
36
+ SOURCE_GENERATE_IAM_ROLE,
37
+ SQS_RESOURCE
37
38
  } = require("../../../../../../MainLibs/src/Consts");
38
39
 
39
40
  const templatePath = path.join(__dirname, "template.ejs");
@@ -50,26 +51,51 @@ function data(_izContext, flowSchema, srcPath) {
50
51
  }
51
52
 
52
53
  function createSourceParams(_izContext, flowSchema, srcPath) {
53
- let functionName = upperCase(flowSchema.flowTag);
54
+ let functionName = upperCase(FUNCTION_NAME.flowSchemaExternalTopic);
54
55
  let handlerType = upperCase(HANDLER.hdrSqs);
55
56
  let externalTopicName = FUNCTION_NAME.flowSchemaExternalTopic + 'Out';
56
- let externalTopicShortName = 'ExtTopicOut';
57
- let functionConfig = upperCase(flowSchema.flowTag) + externalTopicShortName + upperCase(shortNameHandler(handlerType));
57
+ let functionConfig = "ExtTopicOut" + upperCase(shortNameHandler(handlerType));
58
58
  let additionalResourcePermission = defaultIamRolePerAction();
59
- const handler = HANDLER.hdrSqs; // Using hdrSqs as the default handler
60
- const action = flowSchema.flowTag || 'defaultAction'; // Using flowTag as the action name
61
- const event = resourceNames(RESOURCE_CLASSES.sqs, upperCase(action) + upperCase(handler));
62
-
59
+ let flowStepInSplitKey = Object.keys(flowSchema.flowSteps)[0].split("_");
60
+ // const action = flowSchema.flowTag || 'defaultAction'; // Using flowTag as the action name
61
+ // const event = resourceNames(RESOURCE_CLASSES.sqs, upperCase(action) + upperCase(handler));
62
+ additionalResourcePermission.push(
63
+ createIamRole(
64
+ {
65
+ [RESOURCE_CLASSES.sqs]: [
66
+ SQS_RESOURCE.getQueueAttributes,
67
+ SQS_RESOURCE.receiveMessage,
68
+ SQS_RESOURCE.deleteMessage,
69
+ ]
70
+ },
71
+ [
72
+ resourceNames(RESOURCE_CLASSES.sqs, functionName + handlerType),
73
+ resourceNames(RESOURCE_CLASSES.sqs, functionName + handlerType + "DLQ"),
74
+ // resourceNames(RESOURCE_CLASSES.sqs, functionName + "Out"),
75
+ // resourceNames(RESOURCE_CLASSES.sqs, functionName + "OutDLQ"),
76
+ ]
77
+ ),
78
+ // createIamRole(
79
+ // {
80
+ // [RESOURCE_CLASSES.sns]: [
81
+ // SNS_RESOURCE.publish,
82
+ // ]
83
+ // },
84
+ // [
85
+ // resourceNames(RESOURCE_CLASSES.sns, flowStepInSplitKey[2] + flowStepInSplitKey[3]),
86
+ // ]
87
+ // )
88
+ );
63
89
  return {
64
90
  templatePath: templatePath,
65
91
  templateData: {
66
- resourceLocation: SOURCE_PATH.resourceLocationWebSocket,
67
- event,
92
+ resourceLocation: path.join(SOURCE_PATH.resourceLocationFlowSchema, flowSchema.flowTag, "source/"),
68
93
  functionName,
69
94
  handlerType,
70
95
  functionNameConfig: functionConfig,
71
96
  roleName: SOURCE_GENERATE_IAM_ROLE.ExternalTopicRole,
72
- externalTopicName
97
+ externalTopicName,
98
+ additionalResourcePermission,
73
99
  },
74
100
  setting: {
75
101
  savePath: path.join(srcPath, SOURCE_PATH.appYaml),
@@ -1,14 +1,14 @@
1
1
  <%_ const join = require('path').join _%>
2
2
  <%- firstLetterUpperCase(functionNameConfig) %>:
3
- handler: <%- join(resourceLocation, functionName, `${firstLetterUpperCase(externalTopicName)}_${firstLetterUpperCase(handlerType)}.main`) %>
3
+ handler: <%- join(resourceLocation, `${firstLetterUpperCase(functionName)}Out_${firstLetterUpperCase(handlerType)}.main`) %>
4
4
  name: ${self:custom.iz_resourcePrefix}<%- firstLetterUpperCase(functionNameConfig) %>
5
5
  events:
6
6
  - sqs:
7
- arn: <%- event %>
7
+ arn: arn:aws:sqs:${self:custom.iz_region}:${self:custom.iz_accountId}:${self:custom.iz_resourcePrefix}<%- firstLetterUpperCase(functionName) + firstLetterUpperCase(handlerType) %>
8
8
  batchSize: 10
9
9
  role: <%- firstLetterUpperCase(roleName) _%>Role
10
- #<#<%_ functionName _%><%_ handlerType _%>IamRole#>
11
- #<#/<%_ functionName _%><%_ handlerType _%>IamRole#>
10
+ #<#<%- functionName %><%- handlerType %>IamRole#>
11
+ #<#/<%- functionName %><%- handlerType %>IamRole#>
12
12
  <%_ function firstLetterUpperCase(text){
13
13
  return text.charAt(0).toUpperCase() + text.slice(1)
14
14
  } _%>
@@ -20,7 +20,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
20
20
  const path = require('path');
21
21
  const { FLOW_SCHEMA_HOOK_STATE, HANDLER } = require('@izara_project/izara-core-library-service-schemas/src/Consts')
22
22
 
23
- const { SOURCE_PATH, FUNCTION_NAME } = require("../../../../../../MainLibs/src/Consts");
23
+ const { SOURCE_PATH, FUNCTION_NAME, SOURCE_GENERATE_IAM_ROLE } = require("../../../../../../MainLibs/src/Consts");
24
24
  const { firstLetterLowerCase: lowerCase, firstLetterUpperCase: upperCase } = require("../../../../../../MainLibs/src/Utils");
25
25
  const templatePath = path.join(__dirname, "template.ejs")
26
26
 
@@ -41,22 +41,21 @@ function createParamsForCreateSource(_izContext, flowSchema, srcPath) {
41
41
  _izContext.logger.error(`flowStepInSplitKey.length < 4: ${flowStepInSplitKey.length} ${flowSchema.flowTag}`);
42
42
  return null;
43
43
  }
44
- const ExternalTopicName = FUNCTION_NAME.flowSchemaExternalTopic + 'Out';
45
- let queueName = (flowStepInSplitKey[2]) + (flowStepInSplitKey[3]) + 'Out';
46
- let functionName = upperCase(FUNCTION_NAME.flowSchemaExternalTopic)
44
+ let functionName = upperCase(flowSchema.flowTag) + "ExternalTopicOut"
47
45
  let handlerType = upperCase(HANDLER.hdrSqs);
48
46
  return {
49
47
  templatePath: templatePath,
50
48
  templateData: {
51
- queueName,
52
- fileName: ExternalTopicName + 'Out_Main',
53
- functionMain: ExternalTopicName + 'Out',
49
+ queueName: functionName + handlerType,
50
+ fileName: functionName + '_Main',
51
+ functionMain: functionName + 'Main',
54
52
  handler: HANDLER.hdrSqs,
55
53
  firstLetterUpperCase: upperCase,
54
+ functionName
56
55
  },
57
56
  setting: {
58
- savePath: path.join(srcPath, SOURCE_PATH.flowSchemaExternalTopic, flowSchema.flowTag + '/'),
59
- saveFileName: `${functionName}Out_${handlerType}`,
57
+ savePath: path.join(srcPath, SOURCE_PATH.flowSchema, flowSchema.flowTag, 'source/'),
58
+ saveFileName: `${functionName}_${handlerType}`,
60
59
  fileExtension: ".js",
61
60
  isAppend: false
62
61
  }
@@ -29,7 +29,7 @@ const { <%- functionMain %> } =require('./<%- firstLetterUpperCase(fileName) %>.
29
29
  // validate event properties in body.Message of sqs event
30
30
  middlewareHandler.setValidatorSchema(recordHandlerSharedLib.baseValidatorSchema());
31
31
  // set schema for record.body.Message
32
- // const perRecordsValidatorSchema = {
32
+ const perRecordsValidatorSchema = {}
33
33
  // type: "object",
34
34
  // required: ['param1', 'param2', 'param3', 'param4',],
35
35
  // properties: {
@@ -63,18 +63,18 @@ middlewareHandler.setValidatorSchema(recordHandlerSharedLib.baseValidatorSchema(
63
63
  // };
64
64
 
65
65
  // set schema for record.body.MessageAttributes
66
- const messageAttributeValidatorSchema = {
67
- type: "object",
68
- required: ['msgAtrrParam1', 'msgAtrrParam2'],
69
- properties: {
70
- msgAtrrParam1: {
71
- type: "string"
72
- },
73
- msgAtrrParam2: {
74
- type: "object"
75
- }
76
- }
77
- };
66
+ // const messageAttributeValidatorSchema = {
67
+ // type: "object",
68
+ // required: ['msgAtrrParam1', 'msgAtrrParam2'],
69
+ // properties: {
70
+ // msgAtrrParam1: {
71
+ // type: "string"
72
+ // },
73
+ // msgAtrrParam2: {
74
+ // type: "object"
75
+ // }
76
+ // }
77
+ // };
78
78
 
79
79
  module.exports.main = middlewareHandler.wrap(async (event, context, callback) => {
80
80
 
@@ -38,7 +38,7 @@ function data(_izContext, flowSchema, srcPath) {
38
38
  }
39
39
 
40
40
  function createParamsForCreateSource(_izContext, flowSchema, srcPath) {
41
- let functionName = upperCase(FUNCTION_NAME.flowSchemaExternalTopic)
41
+ let functionName = upperCase(flowSchema.flowTag) + "ExternalTopicOut";
42
42
  let snsTopicIn = Object.keys(flowSchema.flowSteps)
43
43
  let snsTopicInWithoutUnderscore = snsTopicIn[0].replace(/_/g, '')
44
44
  let handlerType = upperCase(HANDLER.hdrSqs);
@@ -48,11 +48,11 @@ function createParamsForCreateSource(_izContext, flowSchema, srcPath) {
48
48
  templatePath: templatePath,
49
49
  templateData: {
50
50
  snsTopicIn: snsTopicInWithoutUnderscore,
51
- externalTopicOutMain: FUNCTION_NAME.flowSchemaExternalTopic + 'Out',
51
+ externalTopicOutMain: functionName,
52
52
  },
53
53
  setting: {
54
- savePath: path.join(srcPath, SOURCE_PATH.flowSchemaExternalTopic, flowSchema.flowTag + '/'),
55
- saveFileName: `${functionName}Out_Main`,
54
+ savePath: path.join(srcPath, SOURCE_PATH.flowSchema, flowSchema.flowTag, 'source/'),
55
+ saveFileName: `${functionName}_Main`,
56
56
  fileExtension: ".js",
57
57
  isAppend: false
58
58
  }
@@ -1,70 +1,45 @@
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
16
- <http: //www.gnu.org/licenses />.
17
- */
18
-
19
- 'use strict';
20
-
21
- const hash = require("object-hash");
22
- const getObjectSchema = require('@izara_project/izara-core-library-service-schemas/src/GetObjectSchema');
23
-
1
+ /* Copyright (C) 2020 Sven Mason <http: //izara.io> This program is free
2
+ software: you can redistribute it and/or modify it under the terms of the GNU
3
+ Affero General Public License as published by the Free Software Foundation,
4
+ either version 3 of the License, or (at your option) any later version. This
5
+ program is distributed in the hope that it will be useful, but WITHOUT ANY
6
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
7
+ PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
8
+ You should have received a copy of the GNU Affero General Public License along
9
+ with this program. If not, see <http: //www.gnu.org/licenses />. */ 'use
10
+ strict'; const hash = require("object-hash"); const getObjectSchema =
11
+ require('@izara_project/izara-core-library-service-schemas/src/GetObjectSchema');
24
12
  const dynamodbSharedLib = require('@izara_project/izara-core-library-dynamodb');
25
- const snsSharedLib = require('@izara_project/izara-core-library-sns');
26
- const asyncFlowSharedLib = require('@izara_project/izara-core-library-asynchronous-flow');
27
- const callingFlowSharedLib = require('@izara_project/izara-core-library-calling-flow');
28
- const lambdaSharedLib = require('@izara_project/izara-core-library-lambda');
29
-
30
- const externalRequest = require('@izara_project/izara-core-library-external-request');
31
- const sns = externalRequest.sns
32
-
33
- const utils = require('@izara_project/izara-market-library-service-schemas/src/MainLibs/src/Utils')
34
- const NoRetryError = require('@izara_project/izara-core-library-core').NoRetryError
35
- const { v4: uuidv4 } = require('uuid')
36
- const coreConsts = require("@izara_project/izara-core-library-core/src/Consts");
37
- const { TOPIC_NAME_GENERATE_CODE } = require('@izara_project/izara-market-library-service-schemas/src/GenerateCodeLibs/src/Consts')
38
- /**
39
- *
40
- *
41
- * description of function.
42
- * @param {Object} _izContext
43
- * @param {CorrelationIds} _izContext.correlationIds - property of _izContext
44
- * @param {Logger} _izContext.logger - property of _izContext
45
- * @param {Object} requestParams - request params
46
- * @param {Object} requestParams.identifiers - identifiers for get data
47
- * @param {Object} requestParams.additionalRequest - additionalRequest
48
- *
49
- *
50
- * @returns {object} description of return value
51
- */
52
-
53
- module.exports.<%- externalTopicOutMain%>Main = async (
54
- _izContext,
55
- requestParams,
56
- callingFlowConfig = {},
57
- //(<additionalParams>)
58
- //(</additionalParams>)
59
- ) => {
60
-
61
- try {
62
-
63
- //(<additionalParams>)
64
- //(</additionalParams>)
65
-
66
- } catch (err) {
67
- _izContext.logger.error('error WebSocketInvoke: ', err)
68
- throw (err)
69
- }
70
- }
13
+ const snsSharedLib = require('@izara_project/izara-core-library-sns'); const
14
+ asyncFlowSharedLib =
15
+ require('@izara_project/izara-core-library-asynchronous-flow'); const
16
+ callingFlowSharedLib =
17
+ require('@izara_project/izara-core-library-calling-flow'); const lambdaSharedLib
18
+ = require('@izara_project/izara-core-library-lambda'); const externalRequestSns
19
+ = require('@izara_project/izara-core-library-external-request').sns; const utils
20
+ =
21
+ require('@izara_project/izara-market-library-service-schemas/src/MainLibs/src/Utils')
22
+ const { NoRetryError, consts } =
23
+ require('@izara_project/izara-core-library-core') const { v4: uuidv4 } =
24
+ require('uuid') const { TOPIC_NAME_GENERATE_CODE } =
25
+ require('@izara_project/izara-market-library-service-schemas/src/GenerateCodeLibs/src/Consts')
26
+ const { postToConnection } = require("../../../libs/source/GenerateCodeLibs");
27
+ /** * * * description of function. * @param {Object} _izContext * @param
28
+ {CorrelationIds} _izContext.correlationIds - property of _izContext * @param
29
+ {Logger} _izContext.logger - property of _izContext * @param {Object}
30
+ requestParams - request params * @param {Object} requestParams.identifiers -
31
+ identifiers for get data * @param {Object} requestParams.additionalRequest -
32
+ additionalRequest * * * @returns {object} description of return value */
33
+ module.exports.<%- externalTopicOutMain %>Main = async ( _izContext,
34
+ requestParams, callingFlowConfig = {}, //(<additionalParams
35
+ >) //(</additionalParams
36
+ >) ) => { try { let connectionId =
37
+ _izContext.correlationIds.get(coreConsts.CONNECTION_ID); let correlationId =
38
+ _izContext.correlationIds.get(coreConsts.X_CORRELATION_ID); await
39
+ postToConnection( { message: requestParams }, connectionId ) await
40
+ dynamodbSharedLib.deleteItem(_izContext, await
41
+ dynamodbSharedLib.tableName(_izContext, "WebSocketTask"), { taskKey:
42
+ correlationId, connectionId: connectionId } ) //(<additionalParams
43
+ >) //(</additionalParams
44
+ >) } catch (err) { _izContext.logger.error('error WebSocketInvoke: ', err) throw
45
+ (err) } }
@@ -53,23 +53,11 @@ function data(_izContext, flowSchema, srcPath) {
53
53
  function createSourceParams(_izContext, flowSchema, srcPath) {
54
54
  let functionName = upperCase(flowSchema.flowTag);
55
55
  let handlerType = upperCase("hdrWbs");
56
- let externalTopicName = FUNCTION_NAME.flowSchemaExternalTopic;
57
- let externalTopicShortName = 'ExtTopic';
58
- let functionConfig = upperCase(flowSchema.flowTag) + externalTopicShortName + upperCase(shortNameHandler(handlerType));
56
+ let functionConfig = functionName + "ExternalTopicIn" + upperCase(shortNameHandler(handlerType));
59
57
  let additionalResourcePermission = defaultIamRolePerAction();
60
- let route = "webSocket";
58
+ let route = flowSchema.flowTag;
61
59
 
62
60
  additionalResourcePermission.push(
63
- createIamRole(
64
- {
65
- [RESOURCE_CLASSES.sns]: [
66
- SNS_RESOURCE.publish
67
- ]
68
- },
69
- [
70
- resourceNames(RESOURCE_CLASSES.sns, "InImportBatchMainCreate")
71
- ]
72
- ),
73
61
  createIamRole(
74
62
  {
75
63
  [RESOURCE_CLASSES.dynamoDbTable]: [
@@ -93,47 +81,22 @@ function createSourceParams(_izContext, flowSchema, srcPath) {
93
81
  [
94
82
  resourceNames(RESOURCE_CLASSES.webSocket)
95
83
  ]
96
- )
84
+ ),
97
85
  )
98
86
 
99
- if (flowSchema?.hook) {
100
- for (const [hookName, hookProperties] of Object.entries(flowSchema.hook)) {
101
- if (hookName === FLOW_SCHEMA_HOOK_STATE.beforeCreate) {
102
- for (const hookFunction of hookProperties.functionList) {
103
- if ((hookFunction.event.hasOwnProperty("initialEvent") && (hookFunction.event.initialEvent === true))) {
104
- if (hookFunction?.permission) {
105
- for (const permission of hookFunction.permission) {
106
- additionalResourcePermission.push(
107
- createIamRole(
108
- permission.action,
109
- permission.resource.map(resource =>
110
- externalResourceYaml(
111
- resource.resource,
112
- resource.resourceName,
113
- resource.serviceTag),
114
- permission.effect
115
- )
116
- )
117
- )
118
- }
119
- }
120
- }
121
- }
122
- }
123
- }
124
- }
125
- // console.log("additionalResourcePermission in createObjectS3", JSON.stringify(additionalResourcePermission))
87
+
88
+
126
89
  return {
127
90
  templatePath: templatePath,
128
91
  templateData: {
129
- resourceLocation: SOURCE_PATH.resourceLocationWebSocket,
92
+ resourceLocation: path.join(SOURCE_PATH.resourceLocationFlowSchemaExternalTopic, flowSchema.flowTag, "source/"),
130
93
  functionName,
131
94
  handlerType,
132
95
  functionNameConfig: functionConfig,
133
96
  additionalResourcePermission,
134
97
  route,
135
98
  roleName: SOURCE_GENERATE_IAM_ROLE.ExternalTopicRole,
136
- externalTopicName
99
+ // externalTopicName
137
100
  },
138
101
  setting: {
139
102
  savePath: path.join(srcPath, SOURCE_PATH.appYaml),
@@ -1,6 +1,6 @@
1
1
  <%_ const join = require('path').join; _%>
2
2
  <%- firstLetterUpperCase(functionNameConfig) %>:
3
- handler: <%- join(resourceLocation, functionName, `${firstLetterUpperCase(externalTopicName)}_${firstLetterUpperCase(handlerType)}.main`)%>
3
+ handler: <%- join(resourceLocation, `${firstLetterUpperCase(functionName)}_${firstLetterUpperCase(handlerType)}.main`)%>
4
4
  name: ${self:custom.iz_resourcePrefix}<%- firstLetterUpperCase(functionNameConfig) %>
5
5
  events:
6
6
  - websocket:
@@ -8,8 +8,8 @@
8
8
  # authorizer: ${self:custom.iz_authorizerAppLevel}
9
9
  # identifierResource: 'route.request.header.Auth'
10
10
  role: <%- roleName %>Role
11
- #<#<%- functionName %><%- handlerType %>IamRole#>
12
- #<#/<%- functionName %><%- handlerType %>IamRole#>
11
+ #<#<%- functionName %><%- handlerType %>IamRole#>
12
+ #<#/<%- functionName %><%- handlerType %>IamRole#>
13
13
  <%_ function firstLetterUpperCase(text){
14
14
  return text.charAt(0).toUpperCase() + text.slice(1)
15
15
  } _%>
@@ -36,25 +36,18 @@ function data(_izContext, flowSchema, srcPath) {
36
36
  }
37
37
 
38
38
  function createParamsForCreateSource(_izContext, flowSchema, srcPath) {
39
- // let functionName = upperCase(FUNCTION_NAME.createObjectS3)
40
- let functionName = FUNCTION_NAME.flowSchemaExternalTopic
39
+ let functionName = upperCase(flowSchema.flowTag) + "ExternalTopicIn"
41
40
  let handlerType = "HdrWbs"
42
- let hook = false;
43
- let hookFunctionName;
44
- let isAsync = false;
45
41
  const flowTag = flowSchema.flowTag
46
42
  return {
47
43
  templatePath: templatePath,
48
44
  templateData: {
49
- hook: hook,
50
- hookFunctionName: hookFunctionName,
51
- isAsync,
52
45
  functionName: functionName,
53
46
  fileName: upperCase(functionName),
54
- flowTag
47
+ flowTag,
55
48
  },
56
49
  setting: {
57
- savePath: path.join(srcPath, SOURCE_PATH.flowSchemaExternalTopic, flowSchema.flowTag + '/'),
50
+ savePath: path.join(srcPath, SOURCE_PATH.flowSchema, flowSchema.flowTag, 'source/'),
58
51
  saveFileName: `${upperCase(functionName)}_${handlerType}`,
59
52
  fileExtension: ".js",
60
53
  isAppend: false
@@ -1,86 +1,40 @@
1
- /*
2
- Copyright (C) 2021 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 { middlewareHandler, consts } = require("@izara_project/izara-middleware");
21
- // const AWS = require('aws-sdk');
22
- // const api = new AWS.ApiGatewayManagementApi({ endpoint: process.env.iz_webSocketEndpoint });
23
- const dynamodbSharedLib = require('@izara_project/izara-core-library-dynamodb');
24
- const callingFlowSharedLib = require('@izara_project/izara-core-calling-flow');
25
- const hash = require('object-hash');
26
- // const coreConsts = require("@izara_project/izara-core-library-core/src/Consts");
27
- const consts = require('@izara_project/izara-middleware/src/MiddlewareCore/Consts');
28
- const { postToConnection } = require("../../libs/source/ImportDataLib");
29
- const { <%- functionName%>Main } = require("./<%- fileName%>_Main");
30
-
31
- module.exports.main = middlewareHandler.wrap(async (event, context, callback) => {
32
-
33
- event._izContext.logger.debug('Event:', event);
34
-
35
- try {
36
-
37
- if (event.requestContext) {
38
- const route = event.requestContext.routeKey;
39
- const connectionId = event.requestContext.connectionId;
40
- let correlationId = event._izContext.correlationIds.get(consts.X_CORRELATION_ID)
41
-
42
- switch (route) {
43
- case '<%- flowTag%>':
44
- console.log("event in route <%- flowTag%>", event);
45
- let eventParams = JSON.parse(event.body)
46
-
47
- await dynamodbSharedLib.putItem(
48
- event._izContext,
49
- await dynamodbSharedLib.tableName(event._izContext, "WebSocketTask"),
50
- {
51
- taskKey: correlationId,
52
- connectionId: connectionId,
53
- }
54
- )
55
-
56
- let callingFlow = eventParams?.callingFlow ? eventParams.callingFlow : {};
57
-
58
- await <%- functionName%>Main(
59
- event._izContext,
60
- eventParams,
61
- callingFlowSharedLib.addCallingFlowToPassOnProperties(callingFlow)
62
- //(<additionalParams>)
63
- //(</additionalParams>)
64
- )
65
- break
66
- }
67
- } else {
68
- const connId = event.connId;
69
- // await postMessage({ message: event.message }, connId);
70
- await postToConnection({ message: event.message }, connId);
71
- }
72
-
73
- return (izara.response.webSocketSuccess());
74
-
75
- } catch (err) {
76
- const connId = event.requestContext.connectionId
77
- event._izContext.logger.error('Error, WebSocket: ', err);
78
- // await sendErrorMessage({ message: err.message }, connId);
79
- await postToConnection({ message: err.message }, connId);
80
- return (izara.response.failure(err));
81
- }
82
- });
83
- <%_ const join = require('path').join _%>
84
- <%_ function upperCase (text) {
85
- return text.charAt(0).toUpperCase() + text.slice(1)
86
- } _%>
1
+ /* Copyright (C) 2021 Sven Mason <http://izara.io> This program is free
2
+ software: you can redistribute it and/or modify it under the terms of the GNU
3
+ Affero General Public License as published by the Free Software Foundation,
4
+ either version 3 of the License, or (at your option) any later version. This
5
+ program is distributed in the hope that it will be useful, but WITHOUT ANY
6
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
7
+ PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
8
+ You should have received a copy of the GNU Affero General Public License along
9
+ with this program. If not, see <http://www.gnu.org/licenses/>. */ 'use strict';
10
+ const { middlewareHandler, consts } =
11
+ require("@izara_project/izara-middleware"); // const AWS = require('aws-sdk');
12
+ // const api = new AWS.ApiGatewayManagementApi({ endpoint:
13
+ process.env.iz_webSocketEndpoint }); const dynamodbSharedLib =
14
+ require('@izara_project/izara-core-library-dynamodb'); const
15
+ callingFlowSharedLib =
16
+ require('@izara_project/izara-core-library-calling-flow'); const hash =
17
+ require('object-hash'); // const coreConsts =
18
+ require("@izara_project/izara-core-library-core/src/Consts"); const {
19
+ postToConnection } = require("../../../libs/source/GenerateCodeLibs"); const {
20
+ <%- functionName%>Main } = require("./<%- fileName%>_Main"); module.exports.main
21
+ = middlewareHandler.wrap(async (event, context, callback) => {
22
+ event._izContext.logger.debug('Event:', event); try { if (event.requestContext)
23
+ { const route = event.requestContext.routeKey; const connectionId =
24
+ event.requestContext.connectionId; let correlationId =
25
+ event._izContext.correlationIds.get(consts.X_CORRELATION_ID) switch (route) {
26
+ case '<%- flowTag%>': console.log("event in route <%- flowTag%>", event); let
27
+ eventParams = JSON.parse(event.body) await dynamodbSharedLib.putItem(
28
+ event._izContext, await dynamodbSharedLib.tableName(event._izContext,
29
+ "WebSocketTask"), { taskKey: correlationId, connectionId: connectionId,
30
+ originTimestamp: Date.now() } ) let callingFlow = eventParams?.callingFlow ?
31
+ eventParams.callingFlow : {}; await <%- functionName%>Main( event._izContext,
32
+ eventParams, callingFlowSharedLib.addCallingFlowToPassOnProperties(callingFlow)
33
+ //(<additionalParams>) //(</additionalParams>) ) break } } else { const connId =
34
+ event.connId; // await postMessage({ message: event.message }, connId); await
35
+ postToConnection({ message: event.message }, connId); } } catch (err) { const
36
+ connId = event.requestContext.connectionId event._izContext.logger.error('Error,
37
+ WebSocket: ', err); // await sendErrorMessage({ message: err.message }, connId);
38
+ await postToConnection({ message: err.message }, connId); } }); <%_ const join =
39
+ require('path').join _%> <%_ function upperCase (text) { return
40
+ text.charAt(0).toUpperCase() + text.slice(1) } _%>
@@ -23,6 +23,8 @@ const { SOURCE_PATH, FUNCTION_NAME } = require("../../../../../../MainLibs/src/C
23
23
  const { firstLetterLowerCase: lowerCase, firstLetterUpperCase: upperCase } = require("../../../../../../MainLibs/src/Utils");
24
24
  const templatePath = path.join(__dirname, "template.ejs");
25
25
  const getObjectSchema = require('@izara_project/izara-core-library-service-schemas/src/GetObjectSchema')
26
+ const statusFieldTemplate = path.join(__dirname, "../../../createRecordByStatusType/statusFieldTemplate.ejs")
27
+ const storedCacheTemplate = path.join(__dirname, "../../../createRecordByStatusType/storedCacheTemplate.ejs")
26
28
 
27
29
  /**
28
30
  * receive objectSchema
@@ -38,19 +40,24 @@ function data(_izContext, flowSchema, srcPath) {
38
40
  }
39
41
 
40
42
  function createParamsForCreateSource(_izContext, flowSchema, srcPath) {
41
- const functionName = upperCase(FUNCTION_NAME.flowSchemaExternalTopic)
43
+ let functionName = upperCase(flowSchema.flowTag) + "ExternalTopicIn"
42
44
  const splitKey = Object.keys(flowSchema.flowSteps)[0].split('_')
45
+ // stockLocation_Test_flowStep_TopicName_In
43
46
  // let objectSchema = await getObjectSchema.getObjectSchemaCombineFieldNamesWithCache(_izContext, flowSchema.objType)
44
47
  // let fieldNames = Object.keys(objectSchema.fieldNames)
45
48
  return {
46
49
  templatePath: templatePath,
47
50
  templateData: {
48
51
  serviceTag: splitKey[0],
49
- topicName: splitKey[3] + '_' + splitKey[4],
50
- externalTopicMain: FUNCTION_NAME.flowSchemaExternalTopic + 'Main',
52
+ topicName: splitKey[2] + '_' + splitKey[3],
53
+ externalTopicMain: functionName + 'Main',
54
+ storedCacheTemplate,
55
+ statusFieldTemplate,
56
+ statusType: flowSchema.statusType,
57
+ flowTag: flowSchema.flowTag,
51
58
  },
52
59
  setting: {
53
- savePath: path.join(srcPath, SOURCE_PATH.flowSchemaExternalTopic, flowSchema.flowTag + '/'),
60
+ savePath: path.join(srcPath, SOURCE_PATH.flowSchema, flowSchema.flowTag, 'source/'),
54
61
  saveFileName: `${functionName}_Main`,
55
62
  fileExtension: ".js",
56
63
  isAppend: false