@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
package/index.js CHANGED
@@ -23,5 +23,6 @@ module.exports = {
23
23
  generateCodeLibs: require('./src/GenerateCodeLibs'),
24
24
 
25
25
  generateSchemaWithTemplate: require('./src/TemplateManager/src/GenerateSchema').generateSchemaWithTemplate,
26
- generateCodeWithTemplate: require('./src/reStructure/GenerateCode').generateCodeWithTemplate
26
+ generateCodeWithTemplate: require('./src/reStructure/GenerateCode').generateCodeWithTemplate,
27
+ generateSchema: require('./src/reStructure/GenerateSchema')
27
28
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@izara_project/izara-market-library-service-schemas",
3
- "version": "1.0.26",
3
+ "version": "1.0.28",
4
4
  "description": "Schemas for Izara Market project",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -20,14 +20,19 @@
20
20
  "testEnvironment": "node"
21
21
  },
22
22
  "dependencies": {
23
- "@izara_project/izara-core-library-core": "^1.0.16",
23
+ "@izara_project/izara-core-library-core": "^1.0.18",
24
24
  "@izara_project/izara-core-library-external-request": "^1.0.17",
25
- "@izara_project/izara-core-library-service-schemas": "^1.0.44",
25
+ "@izara_project/izara-core-library-service-schemas": "^1.0.48",
26
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",
27
32
  "ejs": "^3.1.10",
28
33
  "js-beautify": "^1.15.4",
29
34
  "lodash": "^4.17.21",
30
35
  "object-hash": "^3.0.0",
31
- "yaml": "^2.7.0"
36
+ "yaml": "^2.7.1"
32
37
  }
33
38
  }
@@ -24,7 +24,8 @@ const PREFIX = {
24
24
  createRel: "createRelationshipEndpoint",
25
25
  deleteRel: "deleteRelationshipEndpoint",
26
26
  updateNode: "updateNodeEndpoint",
27
- createNode: "createNodeEndpoint"
27
+ createNode: "createNodeEndpoint",
28
+ getRel: "getRelationshipEndpoint"
28
29
  }
29
30
 
30
31
  const TOPIC_NAME_GRAPH_HANDLER = {
@@ -39,16 +40,18 @@ const TOPIC_NAME_GRAPH_HANDLER = {
39
40
  inCreateNode: "InCreateNodeV2",
40
41
  outCreateNode: "OutCreateNodeV2",
41
42
  inDeleteNode: "InDeleteNodeV2",
42
- outDeleteNode: "OutDeleteNodeV2"
43
+ outDeleteNode: "OutDeleteNodeV2",
43
44
  }
44
45
 
45
46
  const TOPIC_NAME_GENERATE_CODE = {
46
47
  updateRelComplete: "UpdateRelationshipComplete",
47
48
  createRelComplete: "CreateRelationshipComplete",
48
49
  deleteRelComplete: "DeleteRelationshipComplete",
50
+ getRelComplete: "GetRelationshipComplete",
49
51
  outUpdateRelComplete: "OutUpdateRelationshipComplete",
50
52
  outCreateRelComplete: "OutCreateRelationshipComplete",
51
53
  outDeleteRelComplete: "OutDeleteRelationshipComplete",
54
+ outGetRelComplete: "OutGetRelationshipComplete",
52
55
  updateNodeComplete: "UpdateNodeComplete",
53
56
  outUpdateNodeComplete: "OutUpdateNodeComplete",
54
57
  createNodeComplete: "CreateObjectComplete",
@@ -20,10 +20,10 @@ along with this program.If not, see < http://www.gnu.org/licenses/>.
20
20
  const lodash = require('lodash');
21
21
  const hash = require("object-hash")
22
22
 
23
- const sqsSharedLib = require('@izara_project/izara-shared/src/SqsSharedLib');
24
- const snsSharedLib = require('@izara_project/izara-shared/src/SnsSharedLib');
25
- const inMemoryCacheLib = require('@izara_project/izara-shared/src/InMemoryCacheLib');
26
- const callingFlowSharedLib = require('@izara_project/izara-shared/src/CallingFlowSharedLib');
23
+ const snsSharedLib = require('@izara_project/izara-core-library-sns');
24
+ const sqsSharedLib = require('@izara_project/izara-core-library-sqs');
25
+ const inMemoryCacheLib = require('@izara_project/izara-core-library-core').inMemoryCacheLib;
26
+ const callingFlowSharedLib = require('@izara_project/izara-core-library-calling-flow');
27
27
 
28
28
  const sns = require('@izara_project/izara-core-library-external-request/src/resources/Sns');
29
29
  const sqs = require('@izara_project/izara-core-library-external-request/src/resources/Sqs');
@@ -46,7 +46,7 @@ const {
46
46
  const Logger = require("@izara_project/izara-core-library-logger");
47
47
 
48
48
  const nodeLabelRegexPattern = "^[a-zA-Z0-9_-]+(?:\:[a-zA-Z0-9_-]+)?$"
49
- const { validateObjType } = require('@izara_project/izara-core-library-service-schemas').validateObjType;
49
+ const { validateObjType } = require('@izara_project/izara-shared-service-schemas').validateObjType;
50
50
 
51
51
 
52
52
 
@@ -564,7 +564,7 @@ async function generateDynamoDbIdentifiers(_izContext, objectSchema, reqIdentifi
564
564
  * @param {Object} objectSchema
565
565
  * @param {Object} reqIdentifiers - input identifier from calling function
566
566
  */
567
- const generateDynamoDbIdentifiersWithCache = inMemoryCacheLib.inMemoryCacheLib(
567
+ const generateDynamoDbIdentifiersWithCache = inMemoryCacheLib(
568
568
  generateDynamoDbIdentifiers, // fn
569
569
  { // setting
570
570
  max: 20, maxAge: 86400000, promise: true, profileName: 'generateDynamoDbIdentifiers',
@@ -244,7 +244,9 @@ const FUNCTION_NAME = {
244
244
  deleteNodeComplete: "deleteNodeComplete",
245
245
  createObjectS3: "createObjectS3",
246
246
  createObjectS3Complete: "webSocketTaskComplete",
247
- processAfterUploadS3: "processAfterUploadS3"
247
+ processAfterUploadS3: "processAfterUploadS3",
248
+ getRel: "getRelationship",
249
+ getRelComplete: "getRelationshipComplete"
248
250
  };
249
251
 
250
252
  const SHORT_FUNCTION_NAME = {
@@ -266,6 +268,8 @@ const SHORT_FUNCTION_NAME = {
266
268
  deleteNode: "deleteNode",
267
269
  deleteNodeComplete: "deleteNodeComp",
268
270
  createObjectS3Complete: "webSocketTaskComp",
271
+ getRel: "getRel",
272
+ getRelComplete: "getRelComp"
269
273
  }
270
274
 
271
275
  const getGraphServiceNameFromAllRelSchema = async (_izContext, allRelSchemas) => {
@@ -367,6 +371,7 @@ const SOURCE_GENERATE_IAM_ROLE = {
367
371
  NodeCompleteRole: "NodeCom",
368
372
  RelationshipRole: "Relationship",
369
373
  RelationshipCompleteRole: "RelationshipCom",
374
+ FlowSchemaUploadS3Role: "FlowSchemaUploadS3"
370
375
  };
371
376
 
372
377
  const ADD_ON_DATA_STRUCTURE_TYPE = {
@@ -451,6 +456,42 @@ const PREFIX_RELATIONSHIP = {
451
456
  disabled: "disabled"
452
457
  }
453
458
 
459
+ function checkDynamoTypeRelationship(relationship) {
460
+ let relaitonshipTag;
461
+ let links;
462
+ for (const [relTag, relProperties] of Object.entries(relationship)) {
463
+ relaitonshipTag = relTag
464
+ for (const [storageResourceTag, storageResource] of Object.entries(relProperties.storageResources)) {
465
+ if (storageResource.storageType === STORAGE_TYPES.dynamoDB) {
466
+ for (const link of relProperties.links) {
467
+ if (link.storageResourceTags.includes(storageResourceTag)) {
468
+ links = relProperties.links
469
+ }
470
+ }
471
+ }
472
+ }
473
+ }
474
+ return [relaitonshipTag, links];
475
+ }
476
+ function createDynamoDbComponentByLinks(link, relationshipTag) {
477
+ let tableNameFrom = `${link.from.objType.serviceTag}_${link.from.objType.objectType}__${relationshipTag}__${link.to.objType.serviceTag}_${link.to.objType.objectType}`
478
+ let tableNameTo = `${link.to.objType.serviceTag}_${link.to.objType.objectType}__${relationshipTag}__${link.from.objType.serviceTag}_${link.from.objType.objectType}`
479
+
480
+ let identifiersConcatFrom = `${link.from.objType.serviceTag}_${link.from.objType.objectType}__identifiersConcat`
481
+ let identifiersConcatTo = `${link.to.objType.serviceTag}_${link.to.objType.objectType}__identifiersConcat`
482
+
483
+ let resourceNameFrom = `${upperCase(link.from.objType.objectType) + upperCase(link.to.objType.objectType)}Relationship`
484
+ let resourceNameTo = `${upperCase(link.to.objType.objectType) + upperCase(link.from.objType.objectType)}Relationship`
485
+ return {
486
+ tableNameFrom,
487
+ tableNameTo,
488
+ identifiersConcatFrom,
489
+ identifiersConcatTo,
490
+ resourceNameFrom,
491
+ resourceNameTo
492
+ }
493
+ }
494
+
454
495
  module.exports = {
455
496
  ACTIONS,
456
497
  DEFAULT_HANDLER_PER_ACTION,
@@ -481,5 +522,7 @@ module.exports = {
481
522
  FIELD_NAME_TPYE,
482
523
  ADD_ON_DATA_STRUCTURE_TYPE,
483
524
  ATTRIBUTE_TAG,
484
- PREFIX_RELATIONSHIP
525
+ PREFIX_RELATIONSHIP,
526
+ checkDynamoTypeRelationship,
527
+ createDynamoDbComponentByLinks
485
528
  }
@@ -23,7 +23,6 @@ const {
23
23
  STORAGE_TYPES
24
24
  } = require('@izara_project/izara-core-library-service-schemas/src/Consts');
25
25
 
26
- const { firstLetterUpperCase: upperCase } = require("../../../MainLibs/src/Utils")
27
26
 
28
27
  const { getGraphServiceNameFromGraphServerTagWithCache, getGraphServiceTagWithCache } = require('@izara_project/izara-core-library-service-schemas/src/ServiceConfig');
29
28
 
@@ -20,6 +20,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
20
20
  const { join, resolve } = require("path");
21
21
  const { readFileSync } = require("fs");
22
22
 
23
+ const { validatePathWithRootServicePath } = require("./libs/GenerateCodeLibs")
24
+
23
25
  const templateConfig = require("./TemplateConfig");
24
26
 
25
27
  // SourceManager
@@ -39,6 +41,9 @@ async function generateCodeWithTemplate(_izContext, objSchemaPath) {
39
41
  // point to app/src
40
42
  let saveFilePath = join(objSchemaPath, `../`);
41
43
 
44
+ // point to root folder of service
45
+ let localServicePath = join(saveFilePath, "../../");
46
+
42
47
  // // define path for store yml file
43
48
  const GENERATE_CODE_SOURCE_PATH = {
44
49
  appYaml: join(saveFilePath, SOURCE_PATH.appYaml),
@@ -50,7 +55,6 @@ async function generateCodeWithTemplate(_izContext, objSchemaPath) {
50
55
  generateCodeLib: join(saveFilePath, SOURCE_PATH.generateCodeLib),
51
56
  };
52
57
 
53
-
54
58
  //------ Start Create Source ------
55
59
 
56
60
  // collect all result of template data for execute createSource
@@ -105,9 +109,13 @@ async function generateCodeWithTemplate(_izContext, objSchemaPath) {
105
109
  }
106
110
  }
107
111
 
112
+ // validate path before empty folder
113
+ for (let folderPathToEmpty of Object.values(GENERATE_CODE_SOURCE_PATH)) {
114
+ validatePathWithRootServicePath(localServicePath, folderPathToEmpty)
115
+ }
108
116
 
109
- for (let folderPathToEmpty of Object.keys(GENERATE_CODE_SOURCE_PATH)) {
110
- await deleteFileInDir(GENERATE_CODE_SOURCE_PATH[folderPathToEmpty]);
117
+ for (let folderPathToEmpty of Object.values(GENERATE_CODE_SOURCE_PATH)) {
118
+ await deleteFileInDir(folderPathToEmpty);
111
119
  }
112
120
 
113
121
 
@@ -139,4 +147,15 @@ async function generateCodeWithTemplate(_izContext, objSchemaPath) {
139
147
 
140
148
  module.exports = {
141
149
  generateCodeWithTemplate
142
- }
150
+ }
151
+
152
+
153
+ /*
154
+ GenerateCode will iterate through templateConfig and generate each template dependOn each templateAndData\
155
+
156
+ GenerateSchema now use for generate attribute tree only
157
+ generateSchema can be modify use used depend on use case eg: some objectType have attribute tree inside addOn
158
+ when generateSchema in own service need to generate ref objectRelationship only
159
+ and attribute tree service can generate schema
160
+
161
+ */
@@ -0,0 +1,153 @@
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 { join, resolve } = require("path");
21
+ const { readFileSync } = require("fs");
22
+
23
+ const schemaConfig = require("./SchemaConfig");
24
+
25
+ // SourceManager
26
+ const { deleteFileInDir, createHookFunction } = require("../SourceManager/src/Utils");
27
+ const { createSource } = require("../SourceManager/src/CreateSource");
28
+
29
+ const { SOURCE_PATH } = require('../TemplateManager/src/libs/Consts');
30
+
31
+ const { validatePathWithRootServicePath } = require("./libs/GenerateCodeLibs");
32
+
33
+
34
+
35
+ async function generateSchema(_izContext, objSchemaPath, generateSchemaSettings) {
36
+ try {
37
+ console.log('objSchemaPath', objSchemaPath);
38
+ // --------- Prepare path -------------
39
+ // point to app/src
40
+ let saveFilePath = join(objSchemaPath, `../`);
41
+ console.log("saveFilePath: ", saveFilePath);
42
+
43
+ // point to root folder of service
44
+ let localServicePath = join(saveFilePath, "../../");
45
+ console.log("localServicePath: ", localServicePath);
46
+
47
+
48
+ //------ Start Create Source ------
49
+
50
+ // collect all result of template data for execute createSource
51
+ let allCreateSource = [];
52
+ // collect all path that need to empty before createSource
53
+ let allEmptyPath = new Set();
54
+
55
+
56
+ // Validate that all generateNames in generateSettings are present in the schemaConfig
57
+ const generateNameSet = new Set(Object.keys(schemaConfig.TemplateAndData));
58
+
59
+ // Find any missing generateNames that are not in the schemaConfig
60
+ let missingGenerateName = generateSchemaSettings.
61
+ filter(({ generateName }) => !generateNameSet.has(generateName));
62
+
63
+ // If there are missing generateNames, throw an error with the list of missing names
64
+ if (missingGenerateName.length) {
65
+ throw Error(`Invalid generateName:[ ${missingGenerateName.map(({ generateName }) => generateName).join(", ")} ]`);
66
+ }
67
+
68
+
69
+ // start create generateSchema depend on
70
+ for (const generateSetting of generateSchemaSettings) {
71
+ console.log('Loading template:', generateSetting.generateName);
72
+ console.log('Setting data:', generateSetting);
73
+ console.log('schemaPath:', schemaConfig.TemplateAndData[generateSetting.generateName]);
74
+ console.log('schemaPath:', join(__dirname, schemaConfig.TemplateAndData[generateSetting.generateName]));
75
+
76
+ // get generateSchema template depend on generateName
77
+ let generateSchemaData = require(join(__dirname, schemaConfig.TemplateAndData[generateSetting.generateName]));
78
+ console.log("generateSchemaData: ", generateSchemaData);
79
+
80
+ let createSourceResult = await generateSchemaData(_izContext, objSchemaPath, generateSetting);
81
+
82
+ // Filter out empty or invalid objects before adding to allCreateSource
83
+ if (Array.isArray(createSourceResult)) {
84
+ const validResults = createSourceResult.filter(item =>
85
+ item && item.templatePath && item.templateData && item.setting
86
+ );
87
+ allCreateSource.push(...validResults);
88
+ }
89
+ }
90
+
91
+
92
+ // check each allCreateSource valid
93
+ for (let item of allCreateSource) {
94
+ // throw Error('Skipping invalid source item:', item);
95
+ if (!item || !item.templatePath || !item.templateData || !item.setting) {
96
+ console.log('throw Error Skipping invalid source item:', item);
97
+ throw Error('Skipping invalid source item:', item);
98
+ }
99
+
100
+ const { templatePath, templateData, setting, emptyPath: returnEmptyPath } = item;
101
+ setting.checkCreateSourcePass = true;
102
+
103
+ let [status, errors] = await createSource(
104
+ readFileSync(templatePath, 'utf8'),
105
+ templateData,
106
+ setting,
107
+ );
108
+
109
+ if (status === false) {
110
+ throw Error(errors);
111
+ }
112
+
113
+ allEmptyPath.add(setting.savePath);
114
+ }
115
+
116
+ // validate path before empty folder
117
+ for (let emptyPath of allEmptyPath) {
118
+ console.log("emptyPath: ", emptyPath);
119
+ validatePathWithRootServicePath(localServicePath, emptyPath)
120
+ }
121
+
122
+ for (let emptyPath of allEmptyPath) {
123
+ await deleteFileInDir(emptyPath);
124
+ }
125
+
126
+
127
+ // generate all source
128
+ for (let item of allCreateSource) {
129
+ // throw error if item is invalid
130
+ if (!item || !item.templatePath || !item.templateData || !item.setting) {
131
+ console.log('Throwing invalid source item:', item);
132
+ throw Error('Throwing invalid source item:', item);
133
+ }
134
+
135
+ const { templatePath, templateData, setting } = item;
136
+ setting.checkCreateSourcePass = false;
137
+
138
+ await createSource(
139
+ readFileSync(templatePath, 'utf8'),
140
+ templateData,
141
+ setting,
142
+ );
143
+ }
144
+
145
+ console.log('Generated all source files successfully');
146
+ return 'return values';
147
+ } catch (error) {
148
+ console.error('Error generating code:', error);
149
+ throw error;
150
+ }
151
+ }
152
+
153
+ module.exports = generateSchema
@@ -0,0 +1,29 @@
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
+ module.exports = {
21
+ TemplateAndData: {
22
+ // ** mock schema config **
23
+ mainAttributeTree: './TemplateData/attributeTreeSchema/generateTemplateData.js',
24
+ test: './TemplateData/testTemplate/data.js',
25
+ },
26
+ Plugin: {
27
+
28
+ }
29
+ }
@@ -1,3 +1,23 @@
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
+
1
21
  module.exports = {
2
22
  TemplateAndData: {
3
23
  // ** PerActionEndpoint **
@@ -0,0 +1,104 @@
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
+ // Import required modules
21
+ console.log("generate main attri ");
22
+ const { join } = require('path');
23
+
24
+
25
+ const { data: mainAttributeData } = require('./mainAttributeTreeSchema/data');
26
+
27
+ const serviceSchemaCore = require("@izara_project/izara-core-library-service-schemas");
28
+ const getObjectSchema = serviceSchemaCore.getObjectSchema;
29
+
30
+ const serviceSchemaShared = require('@izara_project/izara-shared-service-schemas');
31
+ const { validateObjType } = serviceSchemaShared.validateObjType
32
+
33
+
34
+ const modules = {
35
+ mainAttributeTreeSchema: require('./mainAttributeTreeSchema/data')
36
+ }
37
+ /**
38
+ * Generates code with templates for different actions
39
+ * @param {Object} _izContext - Context object
40
+ * @param {string} objSchemaPath - Path to the schema
41
+ * @returns {Array} Array of generated code parameters
42
+ */
43
+ async function generateCodeWithTemplate(_izContext, objSchemaPath, settings) {
44
+ try {
45
+ let allCreateSource = [];
46
+ const srcPath = join(objSchemaPath, '../');
47
+
48
+ // {
49
+ // generateName: "mainAttributeTree",
50
+ // objType: {
51
+ // serviceTag: "GenerateCodeTemplate",
52
+ // objectType: "person"
53
+ // },
54
+ // attributeTag: "productAttribute"
55
+ // }
56
+
57
+ if (!settings || !settings.generateName || !settings.objType || !settings.attributeTag) {
58
+ validateObjType(settings.objType);
59
+ throw new Error("Invalid settings object. Must contain objType and attributeTag properties.");
60
+ }
61
+ // const allObjectSchema = await getObjectSchema.getObjSchemaS3WithoutHierarchy(_izContext, objSchemaPath)
62
+ // .then(data => data.records);
63
+
64
+ // const objectSchema = await getObjectSchema.getObjSchemaS3WithHierarchy(_izContext, settings.objType)
65
+ // console.log("allObjectSchema: ", allObjectSchema);
66
+ // console.log("settings: ", settings);
67
+ /*
68
+ use settings to get main objType
69
+ then check if addOnDataStructure is exist
70
+ if exist, check if type is attributeTree and match with attributeTreeTag
71
+ if match, start generate schema of attributeTree
72
+ */
73
+
74
+ /*
75
+ {
76
+ objectSchema
77
+
78
+
79
+ }
80
+ */
81
+ if (settings.generateName === "mainAttributeTree") {
82
+ let objSchemaAttributeTree = await modules.mainAttributeTreeSchema(_izContext, settings, srcPath);
83
+ console.log("objSchemaAttributeTree: ", objSchemaAttributeTree);
84
+ allCreateSource.push(...objSchemaAttributeTree);
85
+
86
+ } else {
87
+ throw Error(`Generate attribute tree schema Invalid generateName:${settings.generateName} `);
88
+ }
89
+
90
+
91
+ // will receive objSchemaPath and prepare params for each data function
92
+ // then data function will return params for createSource
93
+
94
+ // (template, data, { savePath, hookPath, saveFileName, fileExtension, initialData, isAppend = false, checkCreateSourcePass = false })
95
+
96
+
97
+ return allCreateSource;
98
+ } catch (error) {
99
+ _izContext.logger.error('Error generating code with template perActionComplete:', error);
100
+ return [];
101
+ }
102
+ }
103
+
104
+ module.exports = generateCodeWithTemplate;
@@ -0,0 +1,21 @@
1
+ const izara = require("@izara_project/izara-middleware");
2
+ let { pattern } = izara.validatorSchema.stringNotEmpty(); // should not be empty string
3
+
4
+ module.exports = [
5
+ {
6
+ objectType: "<%- objectType %>",
7
+ overWriteHandlers: { // optional, if not set will create default handlers, if empty will not create handler and main function
8
+ //(<overWriteHandlers<%- objectType %>>)
9
+ //(</overWriteHandlers<%- objectType %>>)
10
+ },
11
+ overwriteGeneratedMainFunction: [
12
+ //(<overwriteGeneratedMainFunction<%- objectType %>>)
13
+ //(</overwriteGeneratedMainFunction<%- objectType %>>)
14
+ ],
15
+ canDelete: true,
16
+ storageResources: <%- storageResources %>,
17
+ fieldNames: <%- fieldNames %>,
18
+ compositeKeyDeliminator: "<%- compositeKeyDeliminator %>",
19
+ identifiers: <%- identifiers %>
20
+ }
21
+ ]