@izara_project/izara-market-library-service-schemas 1.0.26 → 1.0.28

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 (148) hide show
  1. package/index.js +2 -1
  2. package/package.json +9 -4
  3. package/src/GenerateCodeLibs/src/Consts.js +5 -2
  4. package/src/GenerateCodeLibs/src/GenerateCodeLibs.js +6 -6
  5. package/src/MainLibs/src/Consts.js +45 -2
  6. package/src/TemplateManager/src/libs/Consts.js +0 -1
  7. package/src/reStructure/GenerateCode.js +23 -4
  8. package/src/reStructure/GenerateSchema.js +153 -0
  9. package/src/reStructure/SchemaConfig.js +29 -0
  10. package/src/reStructure/TemplateConfig.js +20 -0
  11. package/src/reStructure/TemplateData/attributeTreeSchema/generateTemplateData.js +104 -0
  12. package/src/reStructure/TemplateData/attributeTreeSchema/mainAttributeTreeSchema/attributeLinkTemplate.ejs +21 -0
  13. package/src/reStructure/TemplateData/attributeTreeSchema/mainAttributeTreeSchema/data.js +188 -0
  14. package/src/reStructure/TemplateData/attributeTreeSchema/mainAttributeTreeSchema/request.json +11 -0
  15. package/src/reStructure/TemplateData/externalService/lambdaRole/template.ejs +3 -4
  16. package/src/reStructure/TemplateData/externalService/snsTopicSubscriptions/data.js +1 -1
  17. package/src/reStructure/TemplateData/findData/handler/template.ejs +1 -1
  18. package/src/reStructure/TemplateData/findData/mainFunction/template.ejs +3 -3
  19. package/src/reStructure/TemplateData/flowSchema/components/upload/confirmReserved/functionYaml/data.js +3 -1
  20. package/src/reStructure/TemplateData/flowSchema/components/upload/confirmReserved/functionYaml/template.ejs +1 -14
  21. package/src/reStructure/TemplateData/flowSchema/components/upload/confirmReserved/handler/template.ejs +2 -3
  22. package/src/reStructure/TemplateData/flowSchema/components/upload/confirmReserved/mainFunction/template.ejs +2 -3
  23. package/src/reStructure/TemplateData/flowSchema/components/upload/createObject/functionYaml/data.js +4 -2
  24. package/src/reStructure/TemplateData/flowSchema/components/upload/createObject/functionYaml/template.ejs +1 -14
  25. package/src/reStructure/TemplateData/flowSchema/components/upload/createObject/handler/template.ejs +2 -3
  26. package/src/reStructure/TemplateData/flowSchema/components/upload/createObject/mainFunction/template.ejs +5 -6
  27. package/src/reStructure/TemplateData/flowSchema/components/upload/createObjectComplete/functionYaml/data.js +3 -1
  28. package/src/reStructure/TemplateData/flowSchema/components/upload/createObjectComplete/functionYaml/template.ejs +1 -14
  29. package/src/reStructure/TemplateData/flowSchema/components/upload/createObjectComplete/handler/template.ejs +1 -2
  30. package/src/reStructure/TemplateData/flowSchema/components/upload/createObjectComplete/mainFunction/template.ejs +3 -4
  31. package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/getSignUrls/functionYaml/data.js +3 -1
  32. package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/getSignUrls/functionYaml/template.ejs +1 -14
  33. package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/getSignUrls/handler/template.ejs +2 -2
  34. package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/getSignUrls/mainFunction/template.ejs +3 -4
  35. package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/reservedLimit/functionYaml/data.js +3 -1
  36. package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/reservedLimit/functionYaml/template.ejs +1 -14
  37. package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/reservedLimit/handler/template.ejs +2 -3
  38. package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/reservedLimit/mainFunction/template.ejs +5 -6
  39. package/src/reStructure/TemplateData/flowSchema/components/upload/processFile/functionYml/HdrS3/data.js +4 -2
  40. package/src/reStructure/TemplateData/flowSchema/components/upload/processFile/functionYml/HdrS3/template.ejs +1 -14
  41. package/src/reStructure/TemplateData/flowSchema/components/upload/processFile/handler/handlerS3/template.ejs +1 -1
  42. package/src/reStructure/TemplateData/flowSchema/components/upload/processFile/mainFunction/template.ejs +4 -5
  43. package/src/reStructure/TemplateData/flowSchema/components/websocket/connect/functionYaml/data.js +4 -2
  44. package/src/reStructure/TemplateData/flowSchema/components/websocket/dynamoDb/ReservedTableData.js +2 -1
  45. package/src/reStructure/TemplateData/flowSchema/components/websocket/dynamoDb/WebSocketTaskData.js +2 -1
  46. package/src/reStructure/TemplateData/generateRole/createSharedResource.js +10 -0
  47. package/src/reStructure/TemplateData/perActionComplete/create/handler/template.ejs +2 -3
  48. package/src/reStructure/TemplateData/perActionComplete/create/mainFunction/template.ejs +4 -5
  49. package/src/reStructure/TemplateData/perActionComplete/delete/handler/template.ejs +2 -2
  50. package/src/reStructure/TemplateData/perActionComplete/delete/mainFunction/template.ejs +4 -6
  51. package/src/reStructure/TemplateData/perActionComplete/generateTemplateData.js +1 -1
  52. package/src/reStructure/TemplateData/perActionComplete/get/handler/template.ejs +2 -3
  53. package/src/reStructure/TemplateData/perActionComplete/get/mainFunction/template.ejs +4 -6
  54. package/src/reStructure/TemplateData/perActionComplete/update/handler/template.ejs +2 -3
  55. package/src/reStructure/TemplateData/perActionComplete/update/mainFunction/template.ejs +4 -6
  56. package/src/reStructure/TemplateData/perActionComplete/update/sns-in-sqs/data.js +1 -1
  57. package/src/reStructure/TemplateData/perActionEndpoint/handler/api/template.ejs +1 -1
  58. package/src/reStructure/TemplateData/perActionEndpoint/handler/dsq/template.ejs +2 -2
  59. package/src/reStructure/TemplateData/perActionEndpoint/handler/inv/template.ejs +1 -3
  60. package/src/reStructure/TemplateData/perActionEndpoint/handler/sqs/template.ejs +2 -2
  61. package/src/reStructure/TemplateData/perActionEndpoint/handler/webSocket/template.ejs +3 -3
  62. package/src/reStructure/TemplateData/perActionEndpoint/mainFunction/create/template.ejs +6 -7
  63. package/src/reStructure/TemplateData/perActionEndpoint/mainFunction/delete/template.ejs +5 -4
  64. package/src/reStructure/TemplateData/perActionEndpoint/mainFunction/get/template.ejs +5 -6
  65. package/src/reStructure/TemplateData/perActionEndpoint/mainFunction/update/template.ejs +5 -6
  66. package/src/reStructure/TemplateData/processLogical/handler/template.ejs +1 -1
  67. package/src/reStructure/TemplateData/processLogical/mainFunction/template.ejs +5 -6
  68. package/src/reStructure/TemplateData/processLogicalPagination/handler/dsq/template.ejs +1 -1
  69. package/src/reStructure/TemplateData/processLogicalPagination/handler/sqs/template.ejs +1 -1
  70. package/src/reStructure/TemplateData/processLogicalPagination/mainFunction/template.ejs +6 -5
  71. package/src/reStructure/TemplateData/relationshipPerAction/create/action/functionYaml/api/data.js +27 -6
  72. package/src/reStructure/TemplateData/relationshipPerAction/create/action/functionYaml/dsq/data.js +25 -4
  73. package/src/reStructure/TemplateData/relationshipPerAction/create/action/functionYaml/inv/data.js +26 -4
  74. package/src/reStructure/TemplateData/relationshipPerAction/create/action/functionYaml/sqs/data.js +26 -4
  75. package/src/reStructure/TemplateData/relationshipPerAction/create/action/handler/api/template.ejs +1 -1
  76. package/src/reStructure/TemplateData/relationshipPerAction/create/action/handler/dsq/template.ejs +2 -2
  77. package/src/reStructure/TemplateData/relationshipPerAction/create/action/handler/inv/template.ejs +1 -1
  78. package/src/reStructure/TemplateData/relationshipPerAction/create/action/handler/sqs/template.ejs +2 -2
  79. package/src/reStructure/TemplateData/relationshipPerAction/create/action/mainFunction/template.ejs +66 -18
  80. package/src/reStructure/TemplateData/relationshipPerAction/create/complete/handler/sqs/template.ejs +2 -3
  81. package/src/reStructure/TemplateData/relationshipPerAction/create/complete/mainFunction/template.ejs +5 -6
  82. package/src/reStructure/TemplateData/relationshipPerAction/delete/action/functionYaml/api/data.js +25 -4
  83. package/src/reStructure/TemplateData/relationshipPerAction/delete/action/functionYaml/dsq/data.js +25 -4
  84. package/src/reStructure/TemplateData/relationshipPerAction/delete/action/functionYaml/inv/data.js +25 -4
  85. package/src/reStructure/TemplateData/relationshipPerAction/delete/action/functionYaml/sqs/data.js +26 -4
  86. package/src/reStructure/TemplateData/relationshipPerAction/delete/action/handler/api/template.ejs +1 -1
  87. package/src/reStructure/TemplateData/relationshipPerAction/delete/action/handler/dsq/template.ejs +2 -2
  88. package/src/reStructure/TemplateData/relationshipPerAction/delete/action/handler/inv/template.ejs +1 -1
  89. package/src/reStructure/TemplateData/relationshipPerAction/delete/action/handler/sqs/template.ejs +2 -2
  90. package/src/reStructure/TemplateData/relationshipPerAction/delete/action/mainFunction/template.ejs +55 -5
  91. package/src/reStructure/TemplateData/relationshipPerAction/generateTemplateData.js +62 -6
  92. package/src/reStructure/TemplateData/relationshipPerAction/get/action/functionYaml/api/data.js +119 -0
  93. package/src/reStructure/TemplateData/relationshipPerAction/get/action/functionYaml/api/template.ejs +20 -0
  94. package/src/reStructure/TemplateData/relationshipPerAction/get/action/functionYaml/dsq/data.js +131 -0
  95. package/src/reStructure/TemplateData/relationshipPerAction/get/action/functionYaml/dsq/template.ejs +17 -0
  96. package/src/reStructure/TemplateData/relationshipPerAction/get/action/functionYaml/inv/data.js +119 -0
  97. package/src/reStructure/TemplateData/relationshipPerAction/get/action/functionYaml/inv/template.ejs +13 -0
  98. package/src/reStructure/TemplateData/relationshipPerAction/get/action/functionYaml/sqs/data.js +131 -0
  99. package/src/reStructure/TemplateData/relationshipPerAction/get/action/functionYaml/sqs/template.ejs +17 -0
  100. package/src/reStructure/TemplateData/relationshipPerAction/get/action/handler/api/data.js +57 -0
  101. package/src/reStructure/TemplateData/relationshipPerAction/get/action/handler/api/request.json +0 -0
  102. package/src/reStructure/TemplateData/relationshipPerAction/get/action/handler/api/template.ejs +138 -0
  103. package/src/reStructure/TemplateData/relationshipPerAction/get/action/handler/dsq/data.js +58 -0
  104. package/src/reStructure/TemplateData/relationshipPerAction/get/action/handler/dsq/request.json +0 -0
  105. package/src/reStructure/TemplateData/relationshipPerAction/get/action/handler/dsq/template.ejs +183 -0
  106. package/src/reStructure/TemplateData/relationshipPerAction/get/action/handler/inv/data.js +59 -0
  107. package/src/reStructure/TemplateData/relationshipPerAction/get/action/handler/inv/request.json +0 -0
  108. package/src/reStructure/TemplateData/relationshipPerAction/get/action/handler/inv/template.ejs +125 -0
  109. package/src/reStructure/TemplateData/relationshipPerAction/get/action/handler/sqs/data.js +59 -0
  110. package/src/reStructure/TemplateData/relationshipPerAction/get/action/handler/sqs/request.json +0 -0
  111. package/src/reStructure/TemplateData/relationshipPerAction/get/action/handler/sqs/template.ejs +163 -0
  112. package/src/reStructure/TemplateData/relationshipPerAction/get/action/mainFunction/data.js +59 -0
  113. package/src/reStructure/TemplateData/relationshipPerAction/get/action/mainFunction/template.ejs +322 -0
  114. package/src/reStructure/TemplateData/relationshipPerAction/get/action/sns-in-sqs/data.js +77 -0
  115. package/src/reStructure/TemplateData/relationshipPerAction/get/action/sns-in-sqs/snsTemplate.ejs +59 -0
  116. package/src/reStructure/TemplateData/relationshipPerAction/get/action/sns-in-sqs/sqsTemplate.ejs +43 -0
  117. package/src/reStructure/TemplateData/relationshipPerAction/get/complete/functionYaml/data.js +110 -0
  118. package/src/reStructure/TemplateData/relationshipPerAction/get/complete/functionYaml/request.json +0 -0
  119. package/src/reStructure/TemplateData/relationshipPerAction/get/complete/functionYaml/template.ejs +20 -0
  120. package/src/reStructure/TemplateData/relationshipPerAction/get/complete/handler/sqs/data.js +60 -0
  121. package/src/reStructure/TemplateData/relationshipPerAction/get/complete/handler/sqs/request.json +0 -0
  122. package/src/reStructure/TemplateData/relationshipPerAction/get/complete/handler/sqs/template.ejs +125 -0
  123. package/src/reStructure/TemplateData/relationshipPerAction/get/complete/mainFunction/data.js +55 -0
  124. package/src/reStructure/TemplateData/relationshipPerAction/get/complete/mainFunction/request.json +0 -0
  125. package/src/reStructure/TemplateData/relationshipPerAction/get/complete/mainFunction/template.ejs +141 -0
  126. package/src/reStructure/TemplateData/relationshipPerAction/get/complete/sns-in-sqs/data.js +71 -0
  127. package/src/reStructure/TemplateData/relationshipPerAction/get/complete/sns-in-sqs/request.json +0 -0
  128. package/src/reStructure/TemplateData/relationshipPerAction/get/complete/sns-in-sqs/template.ejs +47 -0
  129. package/src/reStructure/TemplateData/relationshipPerAction/get/complete/sns-out/data.js +71 -0
  130. package/src/reStructure/TemplateData/relationshipPerAction/get/complete/sns-out/request.json +0 -0
  131. package/src/reStructure/TemplateData/relationshipPerAction/get/complete/sns-out/template.ejs +10 -0
  132. package/src/reStructure/TemplateData/relationshipPerAction/update/action/functionYaml/api/data.js +25 -22
  133. package/src/reStructure/TemplateData/relationshipPerAction/update/action/functionYaml/dsq/data.js +25 -5
  134. package/src/reStructure/TemplateData/relationshipPerAction/update/action/functionYaml/inv/data.js +26 -5
  135. package/src/reStructure/TemplateData/relationshipPerAction/update/action/functionYaml/sqs/data.js +25 -4
  136. package/src/reStructure/TemplateData/relationshipPerAction/update/action/handler/api/template.ejs +1 -1
  137. package/src/reStructure/TemplateData/relationshipPerAction/update/action/handler/dsq/template.ejs +2 -2
  138. package/src/reStructure/TemplateData/relationshipPerAction/update/action/handler/inv/template.ejs +1 -1
  139. package/src/reStructure/TemplateData/relationshipPerAction/update/action/handler/sqs/template.ejs +2 -2
  140. package/src/reStructure/TemplateData/relationshipPerAction/update/action/mainFunction/template.ejs +55 -7
  141. package/src/reStructure/TemplateData/resourceYaml/dynamodb/defaultDynamoDbTable.js +50 -42
  142. package/src/reStructure/TemplateData/resourceYaml/dynamodb/generateDynamoPerLink.js +98 -0
  143. package/src/reStructure/TemplateData/resourceYaml/dynamodb/mainResourcePerObjectSchemaData.js +4 -5
  144. package/src/reStructure/TemplateData/resourceYaml/dynamodb/template.ejs +1 -1
  145. package/src/reStructure/TemplateData/resourceYaml/generateTemplateData.js +11 -2
  146. package/src/reStructure/TemplateData/testTemplate/data.js +27 -0
  147. package/src/reStructure/TemplateData/testTemplate/template.ejs +5 -0
  148. package/src/reStructure/libs/GenerateCodeLibs.js +38 -0
@@ -52,12 +52,14 @@ const {
52
52
  SAVE_FILE_NAME,
53
53
  FUNCTION_NAME,
54
54
  SNS_RESOURCE,
55
- DYNAMO_RESOURCE,
56
55
  defaultIamRolePerAction,
57
56
  awaitingMultipleStepsRole,
58
57
  shortNameHandler,
59
58
  SHORT_FUNCTION_NAME,
60
- SOURCE_GENERATE_IAM_ROLE
59
+ SOURCE_GENERATE_IAM_ROLE,
60
+ checkDynamoTypeRelationship,
61
+ createDynamoDbComponentByLinks,
62
+ DYNAMO_RESOURCE
61
63
  } = require("../../../../../../../MainLibs/index.js").consts;
62
64
 
63
65
  const templatePath = path.join(__dirname, './template.ejs')
@@ -70,16 +72,16 @@ const templatePath = path.join(__dirname, './template.ejs')
70
72
  * @return {{ templatePath, templateData, setting } }
71
73
  */
72
74
 
73
- function data(_izContext, srcPath) {
75
+ function data(_izContext, allObjectRelationships, srcPath) {
74
76
  let createSourceArray = [];
75
77
 
76
- const createSourceParam = createParamForCreateSource(srcPath);
78
+ const createSourceParam = createParamForCreateSource(allObjectRelationships, srcPath);
77
79
  createSourceArray.push(createSourceParam);
78
80
  return createSourceArray
79
81
  }
80
82
 
81
83
 
82
- function createParamForCreateSource(srcPath) {
84
+ function createParamForCreateSource(allObjectRelationships, srcPath) {
83
85
 
84
86
  let handlerType = HANDLER.hdrDsq
85
87
  let functionName = FUNCTION_NAME.updateRel
@@ -108,6 +110,24 @@ function createParamForCreateSource(srcPath) {
108
110
 
109
111
  additionalResourcePermission.push(awaitingMultipleStepsRole())
110
112
 
113
+ for (const relationship of allObjectRelationships) {
114
+ let [relationshipTag, links] = checkDynamoTypeRelationship(relationship)
115
+ for (const link of links) {
116
+ let dynamoComponent = createDynamoDbComponentByLinks(link, relationshipTag)
117
+ additionalResourcePermission.push(
118
+ createIamRole(
119
+ {
120
+ [RESOURCE_CLASSES.dynamoDbTable]: [DYNAMO_RESOURCE.updateItem]
121
+ },
122
+ [
123
+ resourceNames(RESOURCE_CLASSES.dynamoDbTable, upperCase(dynamoComponent.tableNameFrom)),
124
+ resourceNames(RESOURCE_CLASSES.dynamoDbTable, upperCase(dynamoComponent.tableNameTo))
125
+ ]
126
+ )
127
+ )
128
+ }
129
+ }
130
+
111
131
  return {
112
132
  templatePath: templatePath,
113
133
  templateData: {
@@ -54,12 +54,14 @@ const {
54
54
  SAVE_FILE_NAME,
55
55
  FUNCTION_NAME,
56
56
  SNS_RESOURCE,
57
- DYNAMO_RESOURCE,
58
57
  defaultIamRolePerAction,
59
58
  awaitingMultipleStepsRole,
60
59
  shortNameHandler,
61
60
  SHORT_FUNCTION_NAME,
62
- SOURCE_GENERATE_IAM_ROLE
61
+ SOURCE_GENERATE_IAM_ROLE,
62
+ checkDynamoTypeRelationship,
63
+ createDynamoDbComponentByLinks,
64
+ DYNAMO_RESOURCE
63
65
  } = require("../../../../../../../MainLibs/index.js").consts;
64
66
 
65
67
  const templatePath = path.join(__dirname, './template.ejs')
@@ -72,16 +74,16 @@ const templatePath = path.join(__dirname, './template.ejs')
72
74
  * @return {{ templatePath, templateData, setting } }
73
75
  */
74
76
 
75
- function data(_izContext, srcPath) {
77
+ function data(_izContext, allObjectRelationships, srcPath) {
76
78
  let createSourceArray = [];
77
79
 
78
- const createSourceParam = createParamForCreateSource(srcPath);
80
+ const createSourceParam = createParamForCreateSource(allObjectRelationships, srcPath);
79
81
  createSourceArray.push(createSourceParam);
80
82
  return createSourceArray
81
83
  }
82
84
 
83
85
 
84
- function createParamForCreateSource(srcPath) {
86
+ function createParamForCreateSource(allObjectRelationships, srcPath) {
85
87
 
86
88
  let handlerType = HANDLER.hdrInv
87
89
  let functionName = FUNCTION_NAME.updateRel
@@ -98,6 +100,25 @@ function createParamForCreateSource(srcPath) {
98
100
  ]
99
101
  )
100
102
  )
103
+
104
+ for (const relationship of allObjectRelationships) {
105
+ let [relationshipTag, links] = checkDynamoTypeRelationship(relationship)
106
+ for (const link of links) {
107
+ let dynamoComponent = createDynamoDbComponentByLinks(link, relationshipTag)
108
+ additionalResourcePermission.push(
109
+ createIamRole(
110
+ {
111
+ [RESOURCE_CLASSES.dynamoDbTable]: [DYNAMO_RESOURCE.updateItem]
112
+ },
113
+ [
114
+ resourceNames(RESOURCE_CLASSES.dynamoDbTable, upperCase(dynamoComponent.tableNameFrom)),
115
+ resourceNames(RESOURCE_CLASSES.dynamoDbTable, upperCase(dynamoComponent.tableNameTo))
116
+ ]
117
+ )
118
+ )
119
+ }
120
+ }
121
+
101
122
  return {
102
123
  templatePath: templatePath,
103
124
  templateData: {
@@ -56,7 +56,9 @@ const {
56
56
  defaultIamRolePerAction,
57
57
  resourceNames,
58
58
  shortNameHandler,
59
- SOURCE_GENERATE_IAM_ROLE
59
+ SOURCE_GENERATE_IAM_ROLE,
60
+ checkDynamoTypeRelationship,
61
+ createDynamoDbComponentByLinks,
60
62
  } = require("../../../../../../../MainLibs/index.js").consts;
61
63
 
62
64
 
@@ -70,9 +72,9 @@ const templatePath = path.join(__dirname, './template.ejs')
70
72
  * @return {{ templatePath, templateData, setting } }
71
73
  */
72
74
 
73
- function data(_izContext, srcPath) {
75
+ function data(_izContext, allObjectRelationships, srcPath) {
74
76
  let createSourceArray = [];
75
- const createSourceParam = createParamForCreateSource(srcPath);
77
+ const createSourceParam = createParamForCreateSource(allObjectRelationships, srcPath);
76
78
  createSourceArray.push(createSourceParam);
77
79
  // console.log("createSourceArrayInUpdaterelationShipSchemahdrSqs", createSourceArray)
78
80
  return createSourceArray
@@ -80,7 +82,7 @@ function data(_izContext, srcPath) {
80
82
 
81
83
 
82
84
 
83
- function createParamForCreateSource(srcPath) {
85
+ function createParamForCreateSource(allObjectRelationships, srcPath) {
84
86
 
85
87
  let handlerType = HANDLER.hdrSqs
86
88
  let functionName = FUNCTION_NAME.updateRel
@@ -108,8 +110,27 @@ function createParamForCreateSource(srcPath) {
108
110
  ]
109
111
  ),
110
112
  )
113
+
111
114
  additionalResourcePermission.push(awaitingMultipleStepsRole())
112
115
 
116
+ for (const relationship of allObjectRelationships) {
117
+ let [relationshipTag, links] = checkDynamoTypeRelationship(relationship)
118
+ for (const link of links) {
119
+ let dynamoComponent = createDynamoDbComponentByLinks(link, relationshipTag)
120
+ additionalResourcePermission.push(
121
+ createIamRole(
122
+ {
123
+ [RESOURCE_CLASSES.dynamoDbTable]: [DYNAMO_RESOURCE.updateItem]
124
+ },
125
+ [
126
+ resourceNames(RESOURCE_CLASSES.dynamoDbTable, upperCase(dynamoComponent.tableNameFrom)),
127
+ resourceNames(RESOURCE_CLASSES.dynamoDbTable, upperCase(dynamoComponent.tableNameTo))
128
+ ]
129
+ )
130
+ )
131
+ }
132
+ }
133
+
113
134
  return {
114
135
  templatePath: templatePath,
115
136
  templateData: {
@@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
18
18
  'use strict';
19
19
  const izara = require("@izara_project/izara-middleware");
20
20
  const middleware = izara.middlewareHandler;
21
- const callingFlowSharedLib = require('@izara_project/izara-shared/src/CallingFlowSharedLib')
21
+ const callingFlowSharedLib = require('@izara_project/izara-core-library-calling-flow');
22
22
  const {
23
23
  validateSchemaMiddleware
24
24
  } = require('@izara_project/izara-market-library-service-schemas/src/GenerateCodeLibs/src/GenerateCodeLibs');
@@ -19,12 +19,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
19
19
  const izara = require("@izara_project/izara-middleware");
20
20
  const middleware = izara.middlewareHandler;
21
21
 
22
- const callingFlowSharedLib = require('@izara_project/izara-shared/src/CallingFlowSharedLib');
22
+ const callingFlowSharedLib = require('@izara_project/izara-core-library-calling-flow');
23
23
 
24
24
  // const CorrelationIds = require('@izara_project/izara-core-library-correlation-ids')
25
25
  // const Logger = require('@izara_project/izara-core-library-logger');
26
26
  // const IntegrationTestDetail = require('@izara_project/izara-core-library-integration-tests')
27
- const recordHandlerSharedLib = require('@izara_project/izara-shared').recordHandlerSharedLib
27
+ const recordHandlerSharedLib = require('@izara_project/izara-core-library-record-handler');
28
28
  const Logger = require("@izara_project/izara-core-library-logger/src/Logger");
29
29
  const <%- functionName %> = require('./<%- firstLetterUpperCase(functionName) %>_Main');
30
30
 
@@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
18
18
  const izara = require("@izara_project/izara-middleware");
19
19
  const middleware = izara.middlewareHandler;
20
20
 
21
- const callingFlowSharedLib = require('@izara_project/izara-shared/src/CallingFlowSharedLib');
21
+ const callingFlowSharedLib = require('@izara_project/izara-core-library-calling-flow');
22
22
 
23
23
  // const CorrelationIds = require('@izara_project/izara-core-library-correlation-ids')
24
24
  // const Logger = require('@izara_project/izara-core-library-logger');
@@ -18,12 +18,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
18
18
  'use strict';
19
19
  const izara = require("@izara_project/izara-middleware");
20
20
  const middleware = izara.middlewareHandler;
21
- const callingFlowSharedLib = require('@izara_project/izara-shared/src/CallingFlowSharedLib')
21
+ const callingFlowSharedLib = require('@izara_project/izara-core-library-calling-flow');
22
22
  const {
23
23
  validateSchemaMiddleware
24
24
  } = require('@izara_project/izara-market-library-service-schemas/src/GenerateCodeLibs/src/GenerateCodeLibs');
25
25
  const Logger = require('@izara_project/izara-core-library-logger');
26
- const recordHandlerSharedLib = require('@izara_project/izara-shared').recordHandlerSharedLib
26
+ const recordHandlerSharedLib = require('@izara_project/izara-core-library-record-handler');
27
27
 
28
28
  const <%- functionName %> = require('./<%- firstLetterUpperCase(functionName) %>_Main');
29
29
 
@@ -19,13 +19,15 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
19
19
 
20
20
  const hash = require("object-hash");
21
21
 
22
- const callingFlowSharedLib = require('@izara_project/izara-shared/src/CallingFlowSharedLib');
23
- const lambdaSharedLib = require('@izara_project/izara-shared/src/LambdaSharedLib');
22
+ const callingFlowSharedLib = require('@izara_project/izara-core-library-calling-flow');
23
+ const lambdaSharedLib = require("@izara_project/izara-core-library-lambda");
24
+ const snsSharedLib = require("@izara_project/izara-core-library-sns");
25
+ const dynamodbSharedLib = require("@izara_project/izara-core-library-dynamodb");
26
+ const asyncFlowSharedLib = require("@izara_project/izara-core-library-asynchronous-flow");
24
27
 
25
- const snsSharedLib = require('@izara_project/izara-shared/src/SnsSharedLib');
26
- const sns = require("@izara_project/izara-core-library-external-request/src/resources/Sns");
28
+ const identifiersObject = require('@izara_project/izara-core-library-service-schemas/src/IdentifiersObject');
27
29
 
28
- const asyncFlowSharedLib = require('@izara_project/izara-shared/src/AsyncFlowSharedLib');
30
+ const sns = require("@izara_project/izara-core-library-external-request/src/resources/Sns");
29
31
 
30
32
  // const NoRetryError = require('@izara_project/izara-core-library-core/src/NoRetryError');
31
33
 
@@ -265,6 +267,30 @@ module.exports.updateRelationship = async (
265
267
  PREFIX.updateRel // prefix, use constant further
266
268
  )
267
269
  );
270
+ } else if (storageResource.storageType === consts.STORAGE_TYPES.dynamoDB) {
271
+ let tableNameFrom = `${firstObject.objType.serviceTag}_${firstObject.objType.objectType}__${relType.relationshipTag}__${secondObject.objType.serviceTag}_${secondObject.objType.objectType}`;
272
+ let tableNameTo = `${secondObject.objType.serviceTag}_${secondObject.objType.objectType}__${relType.relationshipTag}__${firstObject.objType.serviceTag}_${firstObject.objType.objectType}`;
273
+
274
+ let identifiersConcatFirstObject = await identifiersObject.identifiersConcatFromIdentifiers(_izContext, firstObject.objType, firstObject.identifiers);
275
+ let identifiersConcatSecondObject = await identifiersObject.identifiersConcatFromIdentifiers(_izContext, secondObject.objType, secondObject.identifiers);
276
+ const firstObjectIdentifiersConcat = `${firstObject.objType.serviceTag}_${firstObject.objType.objectType}__identifiersConcat`;
277
+ const secondObjectIdentifiersConcat = `${secondObject.objType.serviceTag}_${secondObject.objType.objectType}__identifiersConcat`;
278
+
279
+ await dynamodbSharedLib.updateItem(_izContext,
280
+ await dynamodbSharedLib.tableName(_izContext, tableNameFrom),
281
+ {
282
+ [identifiersConcatFirstObject]: firstObjectIdentifiersConcat,
283
+ [identifiersConcatSecondObject]: secondObjectIdentifiersConcat
284
+ }
285
+ )
286
+
287
+ await dynamodbSharedLib.updateItem(_izContext,
288
+ await dynamodbSharedLib.tableName(_izContext, tableNameTo),
289
+ {
290
+ [identifiersConcatSecondObject]: secondObjectIdentifiersConcat,
291
+ [identifiersConcatFirstObject]: firstObjectIdentifiersConcat
292
+ }
293
+ )
268
294
  }
269
295
  }
270
296
 
@@ -320,8 +346,30 @@ module.exports.updateRelationship = async (
320
346
  })
321
347
  )
322
348
 
323
- } else {
324
- // if relationshipSchema stored in dynamoDB only will send message to outComplete
349
+ } else if (!awaitingStepIds.length) {
350
+ _izContext.logger.debug("dynamoDb storageResourceTag")
351
+ let messageObject = {
352
+ firstObject: firstObject,
353
+ secondObject: secondObject,
354
+ relType: relType,
355
+ relationshipDirection,
356
+ relationshipProperties
357
+ };
358
+
359
+ if (callingFlowConfig[callingFlowSharedLib.consts.CALLINGFLOW_PROPERTYNAME]) {
360
+ _izContext.logger.debug("have callingFlow");
361
+ messageObject = callingFlowSharedLib.addPassBackPropertiesToSnsResponseMessageObject(callingFlowConfig, messageObject);
362
+
363
+ let messageAttributes = callingFlowSharedLib.addCallingFlowToSnsResponseMessageAttributes(callingFlowConfig, {});
364
+ let sendMessageToOutCreateRelComplete = {
365
+ Message: JSON.stringify(messageObject),
366
+ MessageAttributes: sns.createStringMessageAttributes(_izContext, messageAttributes),
367
+ TopicArn: await snsSharedLib.snsTopicArn(_izContext, TOPIC_NAME_GENERATE_CODE.outCreateRelComplete)
368
+ }
369
+ _izContext.logger.debug("send Message to outCreateRelationshipComplete :::", sendMessageToOutCreateRelComplete);
370
+ await sns.publishAsync(_izContext, sendMessageToOutCreateRelComplete);
371
+ }
372
+
325
373
  }
326
374
 
327
375
  return {
@@ -46,82 +46,88 @@ const createAwaitingMultipleStepDynamoDbData = (_izContext, srcPath) => {
46
46
 
47
47
  defaultDynamoDataLists.push(
48
48
  {
49
- "tableName": "AwaitingMultipleSteps",
50
- "attributes": [
49
+ tableName: "AwaitingMultipleSteps",
50
+ resourceName: "AwaitingMultipleSteps",
51
+ attributes: [
51
52
  {
52
- "keyType": "partitionKey",
53
- "AttributeName": "awaitingStepId",
54
- "AttributeType": "S"
53
+ keyType: "partitionKey",
54
+ AttributeName: "awaitingStepId",
55
+ AttributeType: "S"
55
56
  },
56
57
  {
57
- "keyType": "sortKey",
58
- "AttributeName": "pendingStepId",
59
- "AttributeType": "S"
58
+ keyType: "sortKey",
59
+ AttributeName: "pendingStepId",
60
+ AttributeType: "S"
60
61
  }
61
62
  ]
62
63
  },
63
64
  {
64
- "tableName": "AwaitingMultipleStepByPending",
65
- "attributes": [
65
+ tableName: "AwaitingMultipleStepByPending",
66
+ resourceName: "AwaitingMultipleStepByPending",
67
+ attributes: [
66
68
  {
67
- "keyType": "partitionKey",
68
- "AttributeName": "pendingStepId",
69
- "AttributeType": "S"
69
+ keyType: "partitionKey",
70
+ AttributeName: "pendingStepId",
71
+ AttributeType: "S"
70
72
  },
71
73
  {
72
- "keyType": "sortKey",
73
- "AttributeName": "awaitingStepId",
74
- "AttributeType": "S"
74
+ keyType: "sortKey",
75
+ AttributeName: "awaitingStepId",
76
+ AttributeType: "S"
75
77
  }
76
78
  ]
77
79
  },
78
80
  {
79
- "tableName": "FindDataMain",
80
- "attributes": [
81
+ tableName: "FindDataMain",
82
+ resourceName: "FindDataMain",
83
+ attributes: [
81
84
  {
82
- "keyType": "partitionKey",
83
- "AttributeName": "findDataId",
84
- "AttributeType": "S"
85
+ keyType: "partitionKey",
86
+ AttributeName: "findDataId",
87
+ AttributeType: "S"
85
88
  }
86
89
  ]
87
90
  },
88
91
  {
89
- "tableName": "LogicalResultsMain",
90
- "attributes": [
92
+ tableName: "LogicalResultsMain",
93
+ resourceName: "LogicalResultsMain",
94
+ attributes: [
91
95
  {
92
- "keyType": "partitionKey",
93
- "AttributeName": "logicalResultId",
94
- "AttributeType": "S"
96
+ keyType: "partitionKey",
97
+ AttributeName: "logicalResultId",
98
+ AttributeType: "S"
95
99
  }
96
100
  ]
97
101
  },
98
102
  {
99
- "tableName": "LogicalResultsData",
100
- "attributes": [
103
+ tableName: "LogicalResultsData",
104
+ resourceName: "LogicalResultsData",
105
+ attributes: [
101
106
  {
102
- "keyType": "partitionKey",
103
- "AttributeName": "logicalResultId",
104
- "AttributeType": "S"
107
+ keyType: "partitionKey",
108
+ AttributeName: "logicalResultId",
109
+ AttributeType: "S"
105
110
  },
106
111
  {
107
- "keyType": "sortKey",
108
- "AttributeName": "identifiersId",
109
- "AttributeType": "S"
112
+ keyType: "sortKey",
113
+ AttributeName: "identifiersId",
114
+ AttributeType: "S"
110
115
  }
111
116
  ]
112
117
  },
113
118
  {
114
- "tableName": "AwaitingStep",
115
- "attributes": [
119
+ tableName: "AwaitingStep",
120
+ resourceName: "AwaitingStep",
121
+ attributes: [
116
122
  {
117
- "keyType": "partitionKey",
118
- "AttributeName": "awaitingStepId",
119
- "AttributeType": "S"
123
+ keyType: "partitionKey",
124
+ AttributeName: "awaitingStepId",
125
+ AttributeType: "S"
120
126
  },
121
127
  {
122
- "keyType": "sortKey",
123
- "AttributeName": "pendingStepId",
124
- "AttributeType": "S"
128
+ keyType: "sortKey",
129
+ AttributeName: "pendingStepId",
130
+ AttributeType: "S"
125
131
  }
126
132
  ]
127
133
  }
@@ -140,6 +146,8 @@ const createAwaitingMultipleStepDynamoDbData = (_izContext, srcPath) => {
140
146
  }
141
147
  });
142
148
  }
149
+ console.log("resultsForCreateSource default dynamo", resultsForCreateSource)
150
+
143
151
  return resultsForCreateSource;
144
152
  }
145
153
 
@@ -0,0 +1,98 @@
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 STORAGE_TYPES = {
23
+ dynamoDB: "dynamoDB",
24
+ graph: "graph"
25
+ }
26
+ const templatePath = path.join(__dirname, './template.ejs')
27
+ const { SOURCE_PATH, SAVE_FILE_NAME, checkDynamoTypeRelationship, createDynamoDbComponentByLinks } = require('../../../../MainLibs').consts
28
+
29
+ /**
30
+ * create param of crateSouce for FindData And processLogical
31
+ *
32
+ * @param {Object} _izContext
33
+ * @param {String} srcPath
34
+ * @returns {Object[]}
35
+ */
36
+ const createDynamoPerRelationshipLink = (_izContext, allObjectRelationships, srcPath) => {
37
+ let resultsForCreateSource = [];
38
+ const dynamoTablePerLinks = [];
39
+
40
+ for (const relationship of allObjectRelationships) {
41
+ let [relationshipTag, links] = checkDynamoTypeRelationship(relationship)
42
+ for (const link of links) {
43
+ let dynamoComponent = createDynamoDbComponentByLinks(link, relationshipTag)
44
+ dynamoTablePerLinks.push(
45
+ {
46
+ tableName: dynamoComponent.tableNameFrom,
47
+ resourceName: dynamoComponent.resourceNameFrom,
48
+ attributes: [
49
+ {
50
+ keyType: "partitionKey",
51
+ AttributeName: dynamoComponent.identifiersConcatFrom,
52
+ AttributeType: "S"
53
+ },
54
+ {
55
+ keyType: "sortKey",
56
+ AttributeName: dynamoComponent.identifiersConcatTo,
57
+ AttributeType: "S"
58
+ }
59
+ ]
60
+ },
61
+ {
62
+ tableName: dynamoComponent.tableNameTo,
63
+ resourceName: dynamoComponent.resourceNameTo,
64
+ attributes: [
65
+ {
66
+ keyType: "partitionKey",
67
+ AttributeName: dynamoComponent.identifiersConcatTo,
68
+ AttributeType: "S"
69
+ },
70
+ {
71
+ keyType: "sortKey",
72
+ AttributeName: dynamoComponent.identifiersConcatFrom,
73
+ AttributeType: "S"
74
+ }
75
+ ]
76
+ }
77
+ )
78
+ }
79
+ }
80
+
81
+ for (let dynamoTablePerLink of dynamoTablePerLinks) {
82
+ resultsForCreateSource.push({
83
+ templatePath: templatePath,
84
+ templateData: dynamoTablePerLink,
85
+ setting: {
86
+ initialData: 'Resources:\n',
87
+ savePath: path.join(srcPath, SOURCE_PATH.resourceYaml),
88
+ saveFileName: SAVE_FILE_NAME.dynamoDbYaml,
89
+ fileExtension: '.yml',
90
+ isAppend: true
91
+ }
92
+ });
93
+ }
94
+ console.log("resultsForCreateSource generate per link", resultsForCreateSource)
95
+ return resultsForCreateSource;
96
+ }
97
+
98
+ module.exports = createDynamoPerRelationshipLink
@@ -30,7 +30,7 @@ const STORAGE_TYPES = {
30
30
  dynamoDB: "dynamoDB",
31
31
  graph: "graph"
32
32
  }
33
-
33
+ const { firstLetterUpperCase: upperCase } = require('../../../../MainLibs/src/Utils.js')
34
34
  const { SOURCE_PATH, SAVE_FILE_NAME } = require('../../../../MainLibs/index.js').consts
35
35
  const templatePath = path.join(__dirname, './template.ejs')
36
36
 
@@ -52,7 +52,6 @@ function dataForMainDynamoDbYamlFromObjectSchema(_izContext, objectSchema, srcPa
52
52
  let dynamoDbYamlTempleteData = [];
53
53
 
54
54
  let identifierDetail = {};
55
-
56
55
  for (let identifier of objectSchema.identifiers) { //check identifiers from objectSchema
57
56
  // console.log("identifier");
58
57
  if (identifier.type === "partitionKey" || identifier.type === 'sortKey') {
@@ -141,11 +140,11 @@ function dataForMainDynamoDbYamlFromObjectSchema(_izContext, objectSchema, srcPa
141
140
  )
142
141
  }
143
142
  }
144
-
143
+ templateData.resourceName = upperCase(objectSchema.objectType)
145
144
  dynamoDbYamlTempleteData.push(templateData)
146
- // console.log("templateData")
147
145
  }
148
146
  }
147
+
149
148
  return dynamoDbYamlTempleteData
150
149
  }
151
150
 
@@ -169,7 +168,7 @@ const createSourceDataDynamoDB = (_izContext, objectSchema, srcPath) => {
169
168
  }
170
169
  });
171
170
  }
172
-
171
+ console.log("resultsForCreateSource per objectSchema", resultsForCreateSource)
173
172
 
174
173
  return resultsForCreateSource;
175
174
  }
@@ -1,4 +1,4 @@
1
- <%- tableName %>Table:
1
+ <%- resourceName %>Table:
2
2
  Type: "AWS::DynamoDB::Table"
3
3
  Properties:
4
4
  TableName: ${self:custom.iz_resourcePrefix}<%- tableName %>
@@ -36,7 +36,7 @@ const createSourceSnsAndSqs = require('./sns-in-sqs/snsAndSqsPerActionData');
36
36
  const createDefaultSnsOutForFindDataAndProcessLogical = require('./sns-out/defaultSnsOutForFindDataAndProcessLogical');
37
37
  const createDataForCreateSourceSnsOut = require('./sns-out/data');
38
38
  const createFindDataAndProcessLogicalDefaultSnsInSqs = require('./sns-in-sqs/defaultSnsInSqsForFindDataAndProcessLogical');
39
-
39
+ const createDynamoPerRelationshipLink = require('./dynamodb/generateDynamoPerLink.js')
40
40
  /**
41
41
  * Generates code from templates based on object schemas
42
42
  * @param {Object} _izContext - Context object
@@ -47,6 +47,8 @@ async function generateCodeWithTemplate(_izContext, objSchemaPath) {
47
47
  try {
48
48
  const saveFilePath = join(objSchemaPath, '../');
49
49
  const allObjSchemas = await getAllLocalObjectSchemasWithHierarchy(_izContext, objSchemaPath);
50
+ const allLocalRelationshipSchema = getAllLocalRelationshipSchema(_izContext, objSchemaPath);
51
+ console.log("allLocalRelationship", allLocalRelationshipSchema)
50
52
  let createSourceParams = [];
51
53
  let createdTableYaml = {}; // Declare createdTableYaml
52
54
 
@@ -81,14 +83,21 @@ async function generateCodeWithTemplate(_izContext, objSchemaPath) {
81
83
  const defaultSnsInSqsResources = createFindDataAndProcessLogicalDefaultSnsInSqs(_izContext, saveFilePath);
82
84
  const defaultSnsOutResources = createDefaultSnsOutForFindDataAndProcessLogical(_izContext, saveFilePath);
83
85
 
86
+ const dynamoDbResourcePerRelationshipLink = createDynamoPerRelationshipLink(_izContext, allLocalRelationshipSchema, saveFilePath)
84
87
  // Add default resources to parameter list
85
88
  createSourceParams = [
86
89
  ...createSourceParams,
87
90
  ...defaultDynamoDbResources,
88
91
  ...defaultSnsInSqsResources,
89
- ...defaultSnsOutResources
92
+ ...defaultSnsOutResources,
90
93
  ];
91
94
 
95
+ if (allLocalRelationshipSchema.length) {
96
+ createSourceParams.push(
97
+ ...dynamoDbResourcePerRelationshipLink
98
+ )
99
+ }
100
+
92
101
  return createSourceParams;
93
102
  } catch (error) {
94
103
  _izContext.logger.error('Error generating code with template resourceYaml: ', error);