@izara_project/izara-core-generate-service-code 1.0.65 → 1.0.67

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 (257) hide show
  1. package/README.md +73 -11
  2. package/docs/TriggeredCache Flow.drawio +193 -0
  3. package/docs/test.mmd +47 -0
  4. package/docs/test.png +0 -0
  5. package/index.js +0 -5
  6. package/package.json +7 -6
  7. package/src/compile/compileProject.js +26 -0
  8. package/src/compile/loadSchemas.js +50 -0
  9. package/src/emit/crud/dynamicCrudFlowSchemaTemplate.js +11 -0
  10. package/src/emit/crud/emitCrudApplicationArtifacts.js +161 -0
  11. package/src/emit/crud/emitDynamicCrudFlowSchemas.js +84 -0
  12. package/src/emit/crud/generateCrudApplicationArtifacts.js +16 -0
  13. package/src/emit/crud/generateDynamicCrudFlowSchemas.js +21 -0
  14. package/src/emit/crud/loadLocalSchemaArrays.js +8 -0
  15. package/src/{codeGenerators/app/src/generatedCode/Flow/FlowObjects/templates/crud → emit/crud/templates}/CreateEndpoint_Main.ejs +6 -6
  16. package/src/{codeGenerators/app/src/generatedCode/Flow/FlowObjects/templates/crud → emit/crud/templates}/DeleteEndpoint_Main.ejs +6 -6
  17. package/src/{codeGenerators/app/src/generatedCode/Flow/FlowObjects/templates/step → emit/crud/templates}/FlowEndpointBeforeLogical_Main.ejs +2 -2
  18. package/src/emit/crud/templates/FlowEndpointComplete_Main.ejs +96 -0
  19. package/src/{codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/endpoint → emit/crud/templates}/FlowEndpoint_HdrWbs.ejs +1 -1
  20. package/src/emit/crud/templates/FlowHandler_HdrApi.ejs +69 -0
  21. package/src/{codeGenerators/app/src/generatedCode/ProcessLogical/templates/ProcessLogical_HdrSqs.ejs → emit/crud/templates/FlowHandler_HdrSqs.ejs} +52 -56
  22. package/src/{codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/endpoint → emit/crud/templates}/FlowMain_Wbs.ejs +1 -3
  23. package/src/{codeGenerators/app/src/generatedCode/Flow/FlowObjects/templates/crud → emit/crud/templates}/GetEndpoint_Main.ejs +2 -2
  24. package/src/emit/crud/templates/GetRangeEndpoint_Main.ejs +127 -0
  25. package/src/{codeGenerators/app/src/generatedCode/Flow/FlowObjects/templates/crud → emit/crud/templates}/UpdateEndpoint_Main.ejs +11 -9
  26. package/src/emit/custom/customFlows.js +121 -0
  27. package/src/emit/custom/emitCustomFlowApplicationArtifacts.js +325 -0
  28. package/src/emit/custom/generateCustomFlowApplicationArtifacts.js +22 -0
  29. package/src/{codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/endpoint → emit/custom/templates}/FlowEndpoint_Main.ejs +5 -5
  30. package/src/{codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/step → emit/custom/templates}/FlowStep_Main.ejs +1 -1
  31. package/src/{codeGenerators/app/src/generatedCode/Flow/FlowSchemas → emit/custom}/templates/s3/ConfirmReserved_Main.ejs +5 -5
  32. package/src/{codeGenerators/app/src/generatedCode/Flow/FlowSchemas → emit/custom}/templates/s3/CreateObject_HdrWbs.ejs +1 -1
  33. package/src/{codeGenerators/app/src/generatedCode/Flow/FlowSchemas → emit/custom}/templates/s3/CreateObject_Main.ejs +3 -3
  34. package/src/{codeGenerators/app/src/generatedCode/Flow/FlowSchemas → emit/custom}/templates/s3/CreatePreSignUrl_Main.ejs +4 -5
  35. package/src/{codeGenerators/app/src/generatedCode/Flow/FlowSchemas → emit/custom}/templates/s3/FlowHandler_HdrS3.ejs +2 -8
  36. package/src/{codeGenerators/app/src/generatedCode/Flow/FlowSchemas → emit/custom}/templates/s3/ProcessS3File_Main.ejs +1 -1
  37. package/src/{codeGenerators/app/src/generatedCode/Flow/FlowSchemas → emit/custom}/templates/s3/ReservedLimit_Main.ejs +5 -6
  38. package/src/emit/custom/templates/triggerCache/CheckTriggerCache_HdrSqs.ejs +32 -0
  39. package/src/emit/custom/templates/triggerCache/CheckTriggerCache_Main.ejs +63 -0
  40. package/src/emit/custom/templates/triggerCache/TriggerCacheComplete_Main.ejs +35 -0
  41. package/src/emit/custom/templates/triggerCache/TriggerCache_Main.ejs +16 -0
  42. package/src/emit/function/functionYamlArtifact.js +125 -0
  43. package/src/emit/rbac/emitDynamicRbacFlowSchemas.js +117 -0
  44. package/src/emit/rbac/emitRbacApplicationArtifacts.js +270 -0
  45. package/src/emit/rbac/generateCreateTargetRoleHandler.js +19 -0
  46. package/src/emit/rbac/generateDynamicRbacFlowSchemas.js +21 -0
  47. package/src/emit/rbac/rbacFlowTag.js +7 -0
  48. package/src/emit/rbac/templates/CreateTargetRole_HdrSqs.ejs +24 -0
  49. package/src/emit/rbac/templates/CreateTargetRole_Main.ejs +25 -0
  50. package/src/emit/rbac/templates/DynamicRbacFlowSchema.ejs +5 -0
  51. package/src/emit/rbac/templates/ListRbac_HdrApi.ejs +17 -0
  52. package/src/emit/rbac/templates/ListRbac_HdrSqs.ejs +13 -0
  53. package/src/emit/rbac/templates/ListRbac_Main.ejs +29 -0
  54. package/src/emit/rbac/templates/RbacMutation_Main.ejs +22 -0
  55. package/src/emit/rbac/templates/UserRbacFlow_HdrInv.ejs +10 -0
  56. package/src/emit/rbac/templates/UserRbacFlow_Main.ejs +44 -0
  57. package/src/emit/rbac/templates/UserRoleMutation_Main.ejs +33 -0
  58. package/src/emit/relationship/dynamicRelationshipFlowSchemaTemplate.js +11 -0
  59. package/src/emit/relationship/emitDynamicRelationshipFlowSchemas.js +66 -0
  60. package/src/emit/relationship/emitRelationshipApplicationArtifacts.js +148 -0
  61. package/src/emit/relationship/generateDynamicRelationshipFlowSchemas.js +23 -0
  62. package/src/emit/relationship/generateRelationshipApplicationArtifacts.js +22 -0
  63. package/src/{codeGenerators/app/src/generatedCode/Flow/FlowRelationships/templates/relationship/ProcessChangeRelationshipComplete_Main.ejs → emit/relationship/templates/ChangeRelationshipComplete_Main.ejs} +1 -1
  64. package/src/{codeGenerators/app/src/generatedCode/Flow/FlowRelationships/templates/relationship/ProcessChangeRelationship_Main.ejs → emit/relationship/templates/ChangeRelationship_Main.ejs} +12 -4
  65. package/src/{codeGenerators/app/src/generatedCode/Flow/FlowRelationships/templates/relationship/ProcessCreateRelationshipComplete_Main.ejs → emit/relationship/templates/CreateRelationshipComplete_Main.ejs} +1 -1
  66. package/src/{codeGenerators/app/src/generatedCode/Flow/FlowRelationships/templates/relationship/ProcessCreateRelationship_Main.ejs → emit/relationship/templates/CreateRelationship_Main.ejs} +1 -1
  67. package/src/{codeGenerators/app/src/generatedCode/Flow/FlowRelationships/templates/relationship/ProcessDeleteRelationshipComplete_Main.ejs → emit/relationship/templates/DeleteRelationshipComplete_Main.ejs} +1 -1
  68. package/src/{codeGenerators/app/src/generatedCode/Flow/FlowRelationships/templates/relationship/ProcessDeleteRelationship_Main.ejs → emit/relationship/templates/DeleteRelationship_Main.ejs} +1 -1
  69. package/src/{codeGenerators/app/src/generatedCode/Flow/_shared/handlers → emit/relationship/templates}/FlowHandler_HdrDsq.ejs +1 -1
  70. package/src/emit/relationship/templates/FlowHandler_HdrInv.ejs +45 -0
  71. package/src/{codeGenerators/app/src/generatedCode/Flow/FlowRelationships/templates/relationship/ProcessGetRelationshipComplete_Main.ejs → emit/relationship/templates/GetRelationshipComplete_Main.ejs} +1 -1
  72. package/src/{codeGenerators/app/src/generatedCode/Flow/FlowRelationships/templates/relationship/ProcessGetRelationship_Main.ejs → emit/relationship/templates/GetRelationship_Main.ejs} +1 -1
  73. package/src/{codeGenerators/app/src/generatedCode/Flow/FlowRelationships/templates/relationship/ProcessMoveRelationship_Main.ejs → emit/relationship/templates/MoveRelationship_Main.ejs} +9 -1
  74. package/src/{codeGenerators/app/src/generatedCode/Flow/FlowRelationships/templates/relationship/ProcessUpdateRelationshipComplete_Main.ejs → emit/relationship/templates/UpdateRelationshipComplete_Main.ejs} +1 -1
  75. package/src/{codeGenerators/app/src/generatedCode/Flow/FlowRelationships/templates/relationship/ProcessUpdateRelationship_Main.ejs → emit/relationship/templates/UpdateRelationship_Main.ejs} +1 -1
  76. package/src/emit/resource/emitResourceArtifacts.js +595 -0
  77. package/src/emit/resource/generateResourceArtifacts.js +20 -0
  78. package/src/{codeGenerators/resource/sls_yaml/templates/crud → emit/resource/templates}/ResourceBeforeLogicalYaml.ejs +1 -1
  79. package/src/{codeGenerators/resource/sls_yaml/templates/crud → emit/resource/templates}/ResourceSqsYaml.ejs +6 -6
  80. package/src/{codeGenerators/app/sls_yaml → emit/resource}/templates/SharedResource_Yaml.ejs +8 -8
  81. package/src/emit/system/emitSystemWebSocketArtifacts.js +183 -0
  82. package/src/generate.js +60 -126
  83. package/src/output/commitArtifacts.js +213 -0
  84. package/src/output/mergeHooks.js +55 -0
  85. package/src/output/validateArtifacts.js +62 -0
  86. package/src/plan/buildGenerationPlan.js +50 -0
  87. package/test/core.test.js +159 -0
  88. package/test/createTargetRoleHandler.test.js +68 -0
  89. package/test/crudApplicationArtifacts.test.js +107 -0
  90. package/test/customFlowApplicationArtifacts.test.js +297 -0
  91. package/test/dynamicCrudFlowSchemas.test.js +136 -0
  92. package/test/dynamicRbacFlowSchemas.test.js +101 -0
  93. package/test/dynamicRelationshipFlowSchemas.test.js +99 -0
  94. package/test/functionYamlArtifact.test.js +34 -0
  95. package/test/intTestApi.test.js +29 -0
  96. package/test/publicApi.test.js +209 -0
  97. package/test/relationshipApplicationArtifacts.test.js +68 -0
  98. package/test/resourceArtifacts.test.js +121 -0
  99. package/jsconfig.json +0 -9
  100. package/src/__tests__/getIntTestConfig.test.js +0 -51
  101. package/src/__tests__/intTestGeneratorShared.test.cjs +0 -169
  102. package/src/__tests__/pathIntTest.test.js +0 -103
  103. package/src/codeGenerators/app/initial_setup/InitialSetupGenerator.js +0 -199
  104. package/src/codeGenerators/app/initial_setup/templates/InitialSetup_LambdaRole.ejs +0 -50
  105. package/src/codeGenerators/app/initial_setup/templates/InitialSetup_SnsService.ejs +0 -15
  106. package/src/codeGenerators/app/initial_setup/templates/InitialSetup_TableName.ejs +0 -9
  107. package/src/codeGenerators/app/sls_yaml/FindDataYamlGenerator.js +0 -23
  108. package/src/codeGenerators/app/sls_yaml/FunctionYamlGenerator.js +0 -332
  109. package/src/codeGenerators/app/sls_yaml/ProcessLogicalYamlGenerator.js +0 -21
  110. package/src/codeGenerators/app/sls_yaml/RoleNameConfigGenerator.js +0 -48
  111. package/src/codeGenerators/app/sls_yaml/SharedResourceYamlGenerator.js +0 -503
  112. package/src/codeGenerators/app/sls_yaml/__tests__/SharedResourceYamlGenerator.test.js +0 -235
  113. package/src/codeGenerators/app/sls_yaml/_policy/PolicyRegistry.js +0 -56
  114. package/src/codeGenerators/app/sls_yaml/_policy/__tests__/PolicyRegistry.test.js +0 -33
  115. package/src/codeGenerators/app/sls_yaml/renderYamlTemplate.js +0 -13
  116. package/src/codeGenerators/app/sls_yaml/templates/FindData_Yaml.ejs +0 -10
  117. package/src/codeGenerators/app/sls_yaml/templates/FunctionYaml_Api.ejs +0 -21
  118. package/src/codeGenerators/app/sls_yaml/templates/FunctionYaml_EventBridge.ejs +0 -14
  119. package/src/codeGenerators/app/sls_yaml/templates/FunctionYaml_Inv.ejs +0 -6
  120. package/src/codeGenerators/app/sls_yaml/templates/FunctionYaml_Sqs.ejs +0 -11
  121. package/src/codeGenerators/app/sls_yaml/templates/FunctionYaml_Wbs.ejs +0 -11
  122. package/src/codeGenerators/app/sls_yaml/templates/ProcessLogical_Yaml.ejs +0 -32
  123. package/src/codeGenerators/app/sls_yaml/templates/RoleNameConfig_Yaml.ejs +0 -5
  124. package/src/codeGenerators/app/src/generatedCode/FindData/FindDataGenerator.js +0 -238
  125. package/src/codeGenerators/app/src/generatedCode/FindData/templates/FindData_HdrSqs.ejs +0 -87
  126. package/src/codeGenerators/app/src/generatedCode/FindData/templates/FindData_Main.ejs +0 -108
  127. package/src/codeGenerators/app/src/generatedCode/FindData/templates/GetByStorage/getByDynamo.ejs +0 -32
  128. package/src/codeGenerators/app/src/generatedCode/FindData/templates/GetByStorage/getByGraph.ejs +0 -87
  129. package/src/codeGenerators/app/src/generatedCode/Flow/FlowObjects/.gitkeep +0 -0
  130. package/src/codeGenerators/app/src/generatedCode/Flow/FlowObjects/EndpointsGenerator.js +0 -120
  131. package/src/codeGenerators/app/src/generatedCode/Flow/FlowObjects/templates/step/FlowEndpointComplete_Main.ejs +0 -313
  132. package/src/codeGenerators/app/src/generatedCode/Flow/FlowRbac/RbacFlowGenerator.js +0 -116
  133. package/src/codeGenerators/app/src/generatedCode/Flow/FlowRbac/templates/rbac/CreateRolePermissions.ejs +0 -135
  134. package/src/codeGenerators/app/src/generatedCode/Flow/FlowRbac/templates/rbac/CreateTargetRole.ejs +0 -131
  135. package/src/codeGenerators/app/src/generatedCode/Flow/FlowRbac/templates/rbac/CreateUserRole.ejs +0 -150
  136. package/src/codeGenerators/app/src/generatedCode/Flow/FlowRbac/templates/rbac/DeleteRolePermissions.ejs +0 -132
  137. package/src/codeGenerators/app/src/generatedCode/Flow/FlowRbac/templates/rbac/DeleteTargetRole.ejs +0 -132
  138. package/src/codeGenerators/app/src/generatedCode/Flow/FlowRbac/templates/rbac/DeleteUserFromRole.ejs +0 -150
  139. package/src/codeGenerators/app/src/generatedCode/Flow/FlowRbac/templates/rbac/FlowRbac_Main.ejs +0 -252
  140. package/src/codeGenerators/app/src/generatedCode/Flow/FlowRbac/templates/rbac/ListRolePermissions.ejs +0 -120
  141. package/src/codeGenerators/app/src/generatedCode/Flow/FlowRbac/templates/rbac/ListTargetRole.ejs +0 -122
  142. package/src/codeGenerators/app/src/generatedCode/Flow/FlowRbac/templates/rbac/ListUserInRoles.ejs +0 -117
  143. package/src/codeGenerators/app/src/generatedCode/Flow/FlowRelationships/RelationshipFlowGenerator.js +0 -148
  144. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/.gitkeep +0 -0
  145. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/StatusFieldGenerator.js +0 -109
  146. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/WebSocketGenerator.js +0 -122
  147. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/endpoint/FlowEntryPoint_Main.ejs +0 -38
  148. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/statusField/CompleteStatusFieldSns_Yaml.ejs +0 -52
  149. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/statusField/CompleteStatusField_HdrSqs.ejs +0 -84
  150. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/statusField/CompleteStatusField_Main.ejs +0 -78
  151. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/step/plugIns/FlowStep_ByConfig_Awaiting_Main.ejs +0 -123
  152. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/step/plugIns/FlowStep_ByConfig_Paginated_Main.ejs +0 -59
  153. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/step/plugIns/FlowStep_PlugIn_Main.ejs +0 -72
  154. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/step/plugIns/FlowStep_RecievePlugIn_Main.ejs +0 -76
  155. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/step/plugIns/templateAwaitingStep.ejs +0 -41
  156. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/step/plugIns/templateSendPlugin.ejs +0 -18
  157. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/webSocket/ProcessWebSocketFlow_Yaml.ejs +0 -26
  158. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/webSocket/ProcessWebSocketSub_Yaml.ejs +0 -7
  159. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/webSocket/ProcessWebSocket_HdrSqs.ejs +0 -66
  160. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/webSocket/ProcessWebSocket_Main.ejs +0 -115
  161. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/webSocket/ProcessWebSocket_Yaml.ejs +0 -36
  162. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/webSocket/WebSocketConnect_Main.ejs +0 -52
  163. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/webSocket/WebSocketConnect_Yaml.ejs +0 -13
  164. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/webSocket/WebSocketDynamoDb_Yaml.ejs +0 -28
  165. package/src/codeGenerators/app/src/generatedCode/Flow/_shared/events/BaseDsqHandler.js +0 -63
  166. package/src/codeGenerators/app/src/generatedCode/Flow/_shared/events/BaseSqsHandler.js +0 -66
  167. package/src/codeGenerators/app/src/generatedCode/Flow/_shared/events/__tests__/BaseDsqHandler.test.js +0 -94
  168. package/src/codeGenerators/app/src/generatedCode/Flow/_shared/events/dsq.js +0 -5
  169. package/src/codeGenerators/app/src/generatedCode/Flow/_shared/events/eventBridge.js +0 -33
  170. package/src/codeGenerators/app/src/generatedCode/Flow/_shared/events/extTopic.js +0 -6
  171. package/src/codeGenerators/app/src/generatedCode/Flow/_shared/events/lambdaSyncApi.js +0 -51
  172. package/src/codeGenerators/app/src/generatedCode/Flow/_shared/events/lambdaSyncInv.js +0 -51
  173. package/src/codeGenerators/app/src/generatedCode/Flow/_shared/events/ownTopic.js +0 -54
  174. package/src/codeGenerators/app/src/generatedCode/Flow/_shared/events/registry.js +0 -17
  175. package/src/codeGenerators/app/src/generatedCode/Flow/_shared/events/s3.js +0 -56
  176. package/src/codeGenerators/app/src/generatedCode/Flow/_shared/events/s3Components/ConfirmAfterUploadS3Generator.js +0 -46
  177. package/src/codeGenerators/app/src/generatedCode/Flow/_shared/events/s3Components/CreateObjectGenerator.js +0 -50
  178. package/src/codeGenerators/app/src/generatedCode/Flow/_shared/events/s3Components/CreatePreSignUrlGenerator.js +0 -48
  179. package/src/codeGenerators/app/src/generatedCode/Flow/_shared/events/s3Components/ProcessAfterUploadS3Generator.js +0 -49
  180. package/src/codeGenerators/app/src/generatedCode/Flow/_shared/events/s3Components/ReservedLimitGenerator.js +0 -47
  181. package/src/codeGenerators/app/src/generatedCode/Flow/_shared/shared/eventTypes.js +0 -23
  182. package/src/codeGenerators/app/src/generatedCode/Flow/_shared/shared/flowClassifier.js +0 -50
  183. package/src/codeGenerators/app/src/generatedCode/Flow/_shared/shared/flowEntryPointBase.js +0 -106
  184. package/src/codeGenerators/app/src/generatedCode/Flow/_shared/shared/flowMainFunctionBase.js +0 -172
  185. package/src/codeGenerators/app/src/generatedCode/Flow/_shared/shared/flowNaming.js +0 -37
  186. package/src/codeGenerators/app/src/generatedCode/Flow/_shared/shared/flowSelection.js +0 -19
  187. package/src/codeGenerators/app/src/generatedCode/Flow/_shared/shared/flowStepBase.js +0 -235
  188. package/src/codeGenerators/app/src/generatedCode/Flow/_shared/shared/flowStepNormalizer.js +0 -75
  189. package/src/codeGenerators/app/src/generatedCode/Flow/_shared/shared/flowValidator.js +0 -267
  190. package/src/codeGenerators/app/src/generatedCode/Flow/_shared/shared/propertyNormalizer.js +0 -18
  191. package/src/codeGenerators/app/src/generatedCode/Flow/_shared/shared/registry.js +0 -7
  192. package/src/codeGenerators/app/src/generatedCode/Flow/_shared/shared/roleNameDetection.js +0 -49
  193. package/src/codeGenerators/app/src/generatedCode/Flow/_shared/shared/triggerCacheBase.js +0 -177
  194. package/src/codeGenerators/app/src/generatedCode/Flow/_shared/triggerCache/CheckTriggerCache_HdrSqs.ejs +0 -89
  195. package/src/codeGenerators/app/src/generatedCode/Flow/_shared/triggerCache/CheckTriggerCache_Main.ejs +0 -83
  196. package/src/codeGenerators/app/src/generatedCode/Flow/_shared/triggerCache/ProcessTriggerCache_HdrSqs.ejs +0 -103
  197. package/src/codeGenerators/app/src/generatedCode/Flow/_shared/triggerCache/ProcessTriggerCache_Main.ejs +0 -58
  198. package/src/codeGenerators/app/src/generatedCode/Flow/_shared/triggerCache/TriggerCacheComplete_HdrDsq.ejs +0 -104
  199. package/src/codeGenerators/app/src/generatedCode/Flow/_shared/triggerCache/TriggerCacheComplete_HdrSqs.ejs +0 -88
  200. package/src/codeGenerators/app/src/generatedCode/Flow/_shared/triggerCache/TriggerCacheComplete_Main.ejs +0 -80
  201. package/src/codeGenerators/app/src/generatedCode/Flow/_shared/triggerCache/TriggerCacheQueue_Yaml.ejs +0 -36
  202. package/src/codeGenerators/app/src/generatedCode/Flow/_shared/yaml/SharedFunctionSqs_Yaml.ejs +0 -13
  203. package/src/codeGenerators/app/src/generatedCode/ProcessLogical/ProcessLogicalGenerator.js +0 -29
  204. package/src/codeGenerators/app/src/generatedCode/ProcessLogical/templates/PaginateProcessLogical_HdrDsq.ejs +0 -177
  205. package/src/codeGenerators/app/src/generatedCode/ProcessLogical/templates/PaginateProcessLogical_HdrSqs.ejs +0 -155
  206. package/src/codeGenerators/app/src/generatedCode/ProcessLogical/templates/PaginateProcessLogical_Main.ejs +0 -268
  207. package/src/codeGenerators/app/src/generatedCode/ProcessLogical/templates/ProcessLogical_Main.ejs +0 -450
  208. package/src/codeGenerators/app/src/generatedCode/SystemFlowSchemas/RegisterGenerator.js +0 -149
  209. package/src/codeGenerators/app/src/generatedCode/SystemFlowSchemas/templates/register/RegisterComplete_HdrSqs.ejs +0 -85
  210. package/src/codeGenerators/app/src/generatedCode/SystemFlowSchemas/templates/register/RegisterComplete_Main.ejs +0 -176
  211. package/src/codeGenerators/app/src/generatedCode/SystemFlowSchemas/templates/register/Register_HdrWbs.ejs +0 -80
  212. package/src/codeGenerators/app/src/generatedCode/SystemFlowSchemas/templates/register/Register_Main.ejs +0 -164
  213. package/src/codeGenerators/app/src/generatedCode/libs/ConstsGenerator.js +0 -28
  214. package/src/codeGenerators/app/src/generatedCode/libs/GenerateCodeLibsGenerator.js +0 -28
  215. package/src/codeGenerators/app/src/generatedCode/libs/templates/Consts.ejs +0 -448
  216. package/src/codeGenerators/app/src/generatedCode/libs/templates/GenerateCodeLibs.ejs +0 -124
  217. package/src/codeGenerators/resource/sls_yaml/DynamoDBGenerator.js +0 -87
  218. package/src/codeGenerators/resource/sls_yaml/FlowOutGenerator.js +0 -70
  219. package/src/codeGenerators/resource/sls_yaml/FlowResourceYamlGenerator.js +0 -182
  220. package/src/core/renderTemplateFile.js +0 -22
  221. package/src/core/validate.js +0 -165
  222. package/src/generateCode.js +0 -357
  223. package/src/generateSchema.js +0 -123
  224. package/src/parsers/flowSchemaParser.js +0 -112
  225. package/src/parsers/objectSchemaParser.js +0 -39
  226. package/src/parsers/relationshipSchemaParser.js +0 -51
  227. package/src/schemaGenerators/app/src/schemas/FlowSchemas/FlowSchemaGenerator.js +0 -107
  228. package/src/schemaGenerators/app/src/schemas/FlowSchemas/RbacFlowSchemaGenerator.js +0 -98
  229. package/src/schemaGenerators/app/src/schemas/FlowSchemas/RelationshipFlowSchemaGenerator.js +0 -89
  230. package/src/schemaGenerators/app/src/schemas/FlowSchemas/templates/DynamicFlowSchemaTemplate.ejs +0 -41
  231. package/src/schemaGenerators/app/src/schemas/FlowSchemas/templates/DynamicRbacFlowSchemaTemplate.ejs +0 -20
  232. package/src/schemaGenerators/app/src/schemas/FlowSchemas/templates/RelationshipFlowSchemaTemplate.ejs +0 -33
  233. package/src/schemaGenerators/app/src/schemas/FlowSchemas/templates/UserRbacFlowSchemaTemplate.ejs +0 -22
  234. package/src/schemaGenerators/app/src/schemas/ObjectSchemas/AttributeTreeSchemaGenerator.js +0 -124
  235. package/src/schemaGenerators/app/src/schemas/ObjectSchemas/PropertyValueSchemaGenerator.js +0 -119
  236. package/src/schemaGenerators/app/src/schemas/ObjectSchemas/templates/DynamicAttributeTreeManagerSchemaTemplate.ejs +0 -14
  237. package/src/schemaGenerators/app/src/schemas/ObjectSchemas/templates/DynamicAttributeTreeStandardSchemaTemplate.ejs +0 -13
  238. package/src/schemaGenerators/app/src/schemas/ObjectSchemas/templates/DynamicPropertyValueSchemaTemplate.ejs +0 -15
  239. package/src/schemaGenerators/app/src/schemas/RelationshipSchemas/AttributeTreeRelationshipSchemaGenerator.js +0 -109
  240. package/src/schemaGenerators/app/src/schemas/RelationshipSchemas/PropertyValueRelationshipSchemaGenerator.js +0 -103
  241. package/src/schemaGenerators/app/src/schemas/RelationshipSchemas/__tests__/relationshipSchemaHelpers.test.js +0 -38
  242. package/src/schemaGenerators/app/src/schemas/RelationshipSchemas/relationshipSchemaHelpers.js +0 -40
  243. package/src/schemaGenerators/app/src/schemas/RelationshipSchemas/templates/DynamicAttributeTreeRelationshipSchemaTemplate.ejs +0 -7
  244. package/src/schemaGenerators/app/src/schemas/RelationshipSchemas/templates/DynamicPropertyValueRelationshipSchemaTemplate.ejs +0 -7
  245. package/src/schemaGenerators/app/src/schemas/SystemTextSchemas/SystemTextGenerator.js +0 -102
  246. package/src/schemaGenerators/app/src/schemas/SystemTextSchemas/templates/SystemText_Template.ejs +0 -10
  247. /package/src/{codeGenerators/app/src/generatedCode/Flow/_shared/handlers → emit/crud/templates}/FlowHandler_HdrInv.ejs +0 -0
  248. /package/src/{codeGenerators/app/src/generatedCode/Flow/FlowSchemas → emit/custom}/templates/s3/ConfirmReserved_HdrSqs.ejs +0 -0
  249. /package/src/{codeGenerators/app/src/generatedCode/Flow/FlowSchemas → emit/custom}/templates/s3/CreatePreSignUrl_HdrSqs.ejs +0 -0
  250. /package/src/{codeGenerators/app/src/generatedCode/Flow/FlowSchemas → emit/custom}/templates/s3/ReservedLimit_HdrSqs.ejs +0 -0
  251. /package/src/{codeGenerators/app/src/generatedCode/Flow/_shared/handlers → emit/relationship/templates}/FlowHandler_HdrApi.ejs +0 -0
  252. /package/src/{codeGenerators/app/src/generatedCode/Flow/_shared/handlers → emit/relationship/templates}/FlowHandler_HdrSqs.ejs +0 -0
  253. /package/src/{codeGenerators/app/src/generatedCode/Flow/FlowRelationships/templates/relationship/ProcessMoveRelationshipComplete_Main.ejs → emit/relationship/templates/MoveRelationshipComplete_Main.ejs} +0 -0
  254. /package/src/{codeGenerators/resource/sls_yaml → emit/resource}/templates/DynamoDBTable_Yaml.ejs +0 -0
  255. /package/src/{codeGenerators/resource/sls_yaml → emit/resource}/templates/FlowOut_Yaml.ejs +0 -0
  256. /package/src/{codeGenerators/resource/sls_yaml/templates/crud → emit/resource/templates}/ResourceYaml.ejs +0 -0
  257. /package/src/{codeGenerators/resource/sls_yaml → emit/resource}/templates/SystemDynamoDB_Yaml.ejs +0 -0
@@ -0,0 +1,325 @@
1
+ import ejs from 'ejs';
2
+ import { readFile } from 'node:fs/promises';
3
+
4
+ import {
5
+ renderApiFunctionYaml,
6
+ renderEventBridgeFunctionYaml,
7
+ renderInvFunctionYaml,
8
+ renderSqsFunctionYaml,
9
+ renderWbsFunctionYaml
10
+ } from '../function/functionYamlArtifact.js';
11
+ import { customFlowRoleName, flowDsqSteps, flowExtTopicSteps, generatedOwnTopicFlows, supportedCustomFlows, upperFirst } from './customFlows.js';
12
+
13
+ const YAML_PATH = 'app/sls_yaml/generatedCode/source/flow-schema.yml';
14
+ const TEMPLATE_URL = new URL('../crud/templates/', import.meta.url);
15
+ const CUSTOM_TEMPLATE_URL = new URL('./templates/', import.meta.url);
16
+ const DSQ_TEMPLATE_URL = new URL('../relationship/templates/', import.meta.url);
17
+
18
+ export async function emitCustomFlowApplicationArtifacts(flows, { systemFunctions = [], objects = [] } = {}) {
19
+ const customFlows = supportedCustomFlows(flows);
20
+ const generatedRoots = generatedOwnTopicFlows(flows);
21
+ const steps = flowExtTopicSteps(flows);
22
+ const dsqSteps = flowDsqSteps(flows);
23
+ if (customFlows.length === 0 && generatedRoots.length === 0 && steps.length === 0 && dsqSteps.length === 0 && systemFunctions.length === 0) return [];
24
+
25
+ const emitted = await Promise.all(customFlows.map(flow => emitFlow(flow, objects)));
26
+ const roots = await Promise.all(generatedRoots.map(flow => emitOwnTopicRoot(flow, objects)));
27
+ const stepResults = await Promise.all(steps.map(emitExtTopicStep));
28
+ const dsqStepResults = await Promise.all(dsqSteps.map(emitDsqStep));
29
+ return [
30
+ ...emitted.flatMap(result => result.artifacts),
31
+ ...roots.flatMap(result => result.artifacts),
32
+ ...stepResults.flatMap(result => result.artifacts),
33
+ ...dsqStepResults.flatMap(result => result.artifacts),
34
+ { path: YAML_PATH, content: [...systemFunctions, ...emitted.flatMap(result => result.functions), ...roots.flatMap(result => result.functions), ...stepResults.flatMap(result => result.functions), ...dsqStepResults.flatMap(result => result.functions)].join('\n') }
35
+ ];
36
+ }
37
+
38
+ export function customFlowApplicationManagedPaths(flows, { includeYaml = false } = {}) {
39
+ return [
40
+ ...supportedCustomFlows(flows).flatMap(flow => flowPaths(flow)),
41
+ ...generatedOwnTopicFlows(flows).flatMap(ownTopicRootPaths),
42
+ ...flowExtTopicSteps(flows).flatMap(({ flowTag, stepName }) => {
43
+ const source = `app/src/generatedCode/FlowSchemas/${flowTag}/source`;
44
+ return [`${source}/${flowTag}${stepName}_Main.js`, `${source}/${flowTag}${stepName}_HdrSqs.js`];
45
+ }),
46
+ ...flowDsqSteps(flows).flatMap(({ flowTag, stepName, step }) => {
47
+ const source = `app/src/generatedCode/FlowSchemas/${flowTag}/source`;
48
+ const stepEvents = Array.isArray(step.event) ? step.event : [];
49
+ return [
50
+ ...(stepEvents.includes('extTopic') ? [] : [`${source}/${flowTag}${stepName}_Main.js`]),
51
+ `${source}/${flowTag}${stepName}_HdrDsq.js`
52
+ ];
53
+ }),
54
+ ...(supportedCustomFlows(flows).length > 0 || generatedOwnTopicFlows(flows).length > 0 || flowExtTopicSteps(flows).length > 0 || flowDsqSteps(flows).length > 0 || includeYaml ? [YAML_PATH] : [])
55
+ ];
56
+ }
57
+
58
+
59
+
60
+ async function emitFlow(flow, objects) {
61
+ const tag = upperFirst(flow.flowTag);
62
+ const process = tag;
63
+ const source = `app/src/generatedCode/FlowSchemas/${tag}/source`;
64
+ const handlerRoot = `src/generatedCode/FlowSchemas/${tag}/source`;
65
+ const shared = { flowTag: flow.flowTag, flowStepName: '', mainFileName: `${process}_Main`, functionName: process, startConfig: startConfig(flow) };
66
+ const artifacts = needsProcessMain(flow)
67
+ ? [{ path: `${source}/${process}_Main.js`, content: await renderEndpointMain(flow, process, objects) }]
68
+ : [];
69
+ const functions = [];
70
+
71
+ if (flow.event.includes('extTopic') && !flow.event.includes('ownTopic')) {
72
+ artifacts.push({ path: `${source}/${process}_HdrSqs.js`, content: await render('FlowHandler_HdrSqs.ejs', { ...shared, queueName: `${process}HdrSqs` }) });
73
+ functions.push(renderSqsFunctionYaml({ functionName: `${process}HdrSqs`, handlerPath: `${handlerRoot}/${process}_HdrSqs.main`, roleName: customFlowRoleName(flow.flowTag), queueName: `${process}HdrSqs`, flowTag: flow.flowTag, flowStepName: '' }));
74
+ }
75
+ if (flow.event.includes('dsq')) {
76
+ artifacts.push({ path: `${source}/${process}_HdrDsq.js`, content: await renderDsq('FlowHandler_HdrDsq.ejs', { ...shared, queueName: `${process}HdrDsq` }) });
77
+ functions.push(renderSqsFunctionYaml({ functionName: `${process}HdrDsq`, handlerPath: `${handlerRoot}/${process}_HdrDsq.main`, roleName: customFlowRoleName(flow.flowTag), queueName: `${process}HdrDsq`, flowTag: flow.flowTag, flowStepName: '' }));
78
+ }
79
+ if (flow.event.includes('lambdaSyncInv')) {
80
+ artifacts.push({ path: `${source}/${process}_HdrInv.js`, content: await render('FlowHandler_HdrInv.ejs', shared) });
81
+ functions.push(renderInvFunctionYaml({ functionName: `${process}HdrInv`, handlerPath: `${handlerRoot}/${process}_HdrInv.main`, roleName: customFlowRoleName(flow.flowTag), flowTag: flow.flowTag, flowStepName: '' }));
82
+ }
83
+ if (flow.event.includes('lambdaSyncApi')) {
84
+ artifacts.push({ path: `${source}/${process}_HdrApi.js`, content: await render('FlowHandler_HdrApi.ejs', shared) });
85
+ functions.push(renderApiFunctionYaml({ functionName: `${process}HdrApi`, handlerPath: `${handlerRoot}/${process}_HdrApi.main`, roleName: customFlowRoleName(flow.flowTag), flowTag: flow.flowTag, flowStepName: '' }));
86
+ }
87
+ if (flow.event.includes('eventBridge')) {
88
+ artifacts.push({ path: `${source}/${process}_HdrInv.js`, content: await render('FlowHandler_HdrInv.ejs', shared) });
89
+ functions.push(renderEventBridgeFunctionYaml({ functionName: `${process}HdrInv`, handlerPath: `${handlerRoot}/${process}_HdrInv.main`, roleName: customFlowRoleName(flow.flowTag), flowTag: flow.flowTag, flowStepName: '', schedules: flow.schedules ?? [] }));
90
+ }
91
+ if (flow.event.includes('ownTopic')) {
92
+ const root = await emitOwnTopicRoot(flow, objects);
93
+ artifacts.push(...root.artifacts);
94
+ functions.push(...root.functions);
95
+ }
96
+ if (flow.event.includes('s3')) {
97
+ const s3Artifacts = await emitS3Flow(flow, source, handlerRoot);
98
+ artifacts.push(...s3Artifacts.artifacts);
99
+ functions.push(...s3Artifacts.functions);
100
+ }
101
+ return { artifacts, functions };
102
+ }
103
+
104
+ function flowPaths(flow) {
105
+ const tag = upperFirst(flow.flowTag);
106
+ const process = tag;
107
+ const source = `app/src/generatedCode/FlowSchemas/${tag}/source`;
108
+ const paths = needsProcessMain(flow) ? [`${source}/${process}_Main.js`] : [];
109
+ if (flow.event.includes('extTopic') && !flow.event.includes('ownTopic')) paths.push(`${source}/${process}_HdrSqs.js`);
110
+ if (flow.event.includes('dsq')) paths.push(`${source}/${process}_HdrDsq.js`);
111
+ if (flow.event.includes('lambdaSyncInv') || flow.event.includes('eventBridge')) paths.push(`${source}/${process}_HdrInv.js`);
112
+ if (flow.event.includes('lambdaSyncApi')) paths.push(`${source}/${process}_HdrApi.js`);
113
+ if (flow.event.includes('ownTopic')) paths.push(...ownTopicRootPaths(flow));
114
+ if (flow.event.includes('s3')) {
115
+ ['ConfirmAfterUpload', 'CreateObject', 'CreatePreSignUrl', 'ProcessAfterUpload', 'ReservedLimit'].forEach(action => {
116
+ const handler = action === 'CreateObject' ? 'HdrWbs' : action === 'ProcessAfterUpload' ? 'HdrS3' : 'HdrSqs';
117
+ paths.push(`${source}/${tag}${action}_Main.js`, `${source}/${tag}${action}_${handler}.js`);
118
+ });
119
+ }
120
+ return paths;
121
+ }
122
+
123
+ async function emitExtTopicStep({ flow, step, flowTag, stepName }) {
124
+ const source = `app/src/generatedCode/FlowSchemas/${flowTag}/source`;
125
+ const handlerRoot = `src/generatedCode/FlowSchemas/${flowTag}/source`;
126
+ const functionName = `${flowTag}${stepName}`;
127
+ const mainFileName = `${functionName}_Main`;
128
+ const startConfig = stepConfig(flow, step);
129
+
130
+ if (step.checkTriggerType === 'flowType') {
131
+ const completeStep = flow.flowSteps?.find(s => s.checkTriggerType === 'complete');
132
+ const completeStepName = completeStep ? completeStep.stepName : undefined;
133
+ const queueName = `${functionName}HdrSqs`;
134
+ return {
135
+ artifacts: [
136
+ { path: `${source}/${mainFileName}.js`, content: await renderCustom('triggerCache/CheckTriggerCache_Main.ejs', { functionName, flowTag }) },
137
+ { path: `${source}/${functionName}_HdrSqs.js`, content: await renderCustom('triggerCache/CheckTriggerCache_HdrSqs.ejs', { functionName, queueName }) }
138
+ ],
139
+ functions: [renderSqsFunctionYaml({ functionName: queueName, handlerPath: `${handlerRoot}/${functionName}_HdrSqs.main`, roleName: customFlowRoleName(flow.flowTag), queueName, flowTag, flowStepName: step.stepName, targetCompleteStepName: completeStepName })]
140
+ };
141
+ } else if (step.checkTriggerType === 'complete') {
142
+ const queueName = `${functionName}HdrSqs`;
143
+ return {
144
+ artifacts: [
145
+ { path: `${source}/${mainFileName}.js`, content: await renderCustom('triggerCache/TriggerCacheComplete_Main.ejs', { functionName, flowTag }) },
146
+ { path: `${source}/${functionName}_HdrSqs.js`, content: await render('FlowHandler_HdrSqs.ejs', { flowTag: flow.flowTag, flowStepName: step.stepName, functionName, mainFileName, startConfig, queueName, usePassBack: false }) }
147
+ ],
148
+ functions: [renderSqsFunctionYaml({ functionName: queueName, handlerPath: `${handlerRoot}/${functionName}_HdrSqs.main`, roleName: customFlowRoleName(flow.flowTag), queueName, flowTag, flowStepName: step.stepName })]
149
+ };
150
+ }
151
+
152
+ const artifacts = [{ path: `${source}/${mainFileName}.js`, content: await renderStepMain(functionName) }];
153
+ const functions = [];
154
+
155
+ const stepEvents = Array.isArray(step.event) ? step.event : [];
156
+ const hasSqs = stepEvents.includes('extTopic') || stepEvents.includes('sqs');
157
+
158
+ if (hasSqs) {
159
+ const queueName = `${functionName}HdrSqs`;
160
+ artifacts.push({ path: `${source}/${functionName}_HdrSqs.js`, content: await render('FlowHandler_HdrSqs.ejs', { flowTag: flow.flowTag, flowStepName: step.stepName, functionName, mainFileName, startConfig, queueName }) });
161
+ functions.push(renderSqsFunctionYaml({ functionName: queueName, handlerPath: `${handlerRoot}/${functionName}_HdrSqs.main`, roleName: customFlowRoleName(flow.flowTag), queueName, flowTag, flowStepName: step.stepName }));
162
+ }
163
+
164
+ return { artifacts, functions };
165
+ }
166
+
167
+ async function emitDsqStep({ flow, step, flowTag, stepName }) {
168
+ const source = `app/src/generatedCode/FlowSchemas/${flowTag}/source`;
169
+ const handlerRoot = `src/generatedCode/FlowSchemas/${flowTag}/source`;
170
+ const functionName = `${flowTag}${stepName}`;
171
+ const mainFileName = `${functionName}_Main`;
172
+ const startConfig = stepConfig(flow, step);
173
+
174
+ const stepEvents = Array.isArray(step.event) ? step.event : [];
175
+ const artifacts = stepEvents.includes('extTopic') ? [] : [{ path: `${source}/${mainFileName}.js`, content: await renderStepMain(functionName) }];
176
+ const functions = [];
177
+
178
+ const hasDsq = stepEvents.includes('dsq');
179
+
180
+ if (hasDsq) {
181
+ const queueName = `${functionName}HdrDsq`;
182
+ artifacts.push({ path: `${source}/${functionName}_HdrDsq.js`, content: await renderDsq('FlowHandler_HdrDsq.ejs', { flowTag: flow.flowTag, flowStepName: step.stepName, functionName, mainFileName, startConfig, queueName }) });
183
+ functions.push(renderSqsFunctionYaml({ functionName: queueName, handlerPath: `${handlerRoot}/${functionName}_HdrDsq.main`, roleName: customFlowRoleName(flow.flowTag), queueName, flowTag, flowStepName: step.stepName }));
184
+ }
185
+
186
+ return { artifacts, functions };
187
+ }
188
+
189
+ async function emitOwnTopicRoot(flow, objects) {
190
+ const tag = upperFirst(flow.flowTag);
191
+ const source = `app/src/generatedCode/FlowSchemas/${tag}/source`;
192
+ const handlerRoot = `src/generatedCode/FlowSchemas/${tag}/source`;
193
+ const mainFileName = `${tag}_Main`;
194
+ const wbsMainFileName = `${tag}_WbsMain`;
195
+ const shared = { flowTag: flow.flowTag, flowStepName: '', upperCaseFlowTag: tag, startConfig: startConfig(flow) };
196
+ return {
197
+ artifacts: [
198
+ { path: `${source}/${mainFileName}.js`, content: await renderEndpointMain(flow, mainFileName, objects) },
199
+ { path: `${source}/${tag}_HdrSqs.js`, content: await render('FlowHandler_HdrSqs.ejs', { ...shared, functionName: mainFileName, mainFileName, queueName: `${tag}HdrSqs` }) },
200
+ { path: `${source}/${wbsMainFileName}.js`, content: await render('FlowMain_Wbs.ejs', { ...shared, functionName: wbsMainFileName }) },
201
+ { path: `${source}/${tag}_HdrWbs.js`, content: await render('FlowEndpoint_HdrWbs.ejs', { ...shared, functionName: tag, mainFileName: wbsMainFileName, route: tag }) }
202
+ ],
203
+ functions: [
204
+ renderWbsFunctionYaml({ functionName: `${tag}HdrWbs`, handlerPath: `${handlerRoot}/${tag}_HdrWbs.main`, roleName: customFlowRoleName(flow.flowTag), routeName: tag, flowTag: flow.flowTag, flowStepName: '' }),
205
+ renderSqsFunctionYaml({ functionName: `${tag}HdrSqs`, handlerPath: `${handlerRoot}/${tag}_HdrSqs.main`, roleName: customFlowRoleName(flow.flowTag), queueName: `${tag}HdrSqs`, flowTag: flow.flowTag, flowStepName: '' })
206
+ ]
207
+ };
208
+ }
209
+
210
+ function ownTopicRootPaths(flow) {
211
+ const tag = upperFirst(flow.flowTag);
212
+ const source = `app/src/generatedCode/FlowSchemas/${tag}/source`;
213
+ return [`${source}/${tag}_Main.js`, `${source}/${tag}_HdrSqs.js`, `${source}/${tag}_WbsMain.js`, `${source}/${tag}_HdrWbs.js`];
214
+ }
215
+
216
+ function needsProcessMain(flow) {
217
+ return !isS3Only(flow) && !flow.event.includes('ownTopic') && flow.event.some(event => event !== 'ownTopic' && event !== 's3');
218
+ }
219
+
220
+ async function emitS3Flow(flow, source, handlerRoot) {
221
+ const tag = upperFirst(flow.flowTag);
222
+ const roleName = customFlowRoleName(flow.flowTag);
223
+ const parts = [
224
+ { action: 'CreateObject', handler: 'HdrWbs', type: 'wbs', mainTemplate: 'CreateObject_Main.ejs', handlerTemplate: 'CreateObject_HdrWbs.ejs' },
225
+ { action: 'ReservedLimit', handler: 'HdrSqs', type: 'sqs', mainTemplate: 'ReservedLimit_Main.ejs', handlerTemplate: 'ReservedLimit_HdrSqs.ejs' },
226
+ { action: 'CreatePreSignUrl', handler: 'HdrSqs', type: 'sqs', mainTemplate: 'CreatePreSignUrl_Main.ejs', handlerTemplate: 'CreatePreSignUrl_HdrSqs.ejs' },
227
+ { action: 'ProcessAfterUpload', handler: 'HdrS3', type: 'inv', mainTemplate: 'ProcessS3File_Main.ejs', handlerTemplate: 'FlowHandler_HdrS3.ejs' },
228
+ { action: 'ConfirmAfterUpload', handler: 'HdrSqs', type: 'sqs', mainTemplate: 'ConfirmReserved_Main.ejs', handlerTemplate: 'ConfirmReserved_HdrSqs.ejs' }
229
+ ];
230
+ const emitted = await Promise.all(parts.map(async ({ action, handler, type, mainTemplate, handlerTemplate }) => {
231
+ const functionName = `${tag}${action}`;
232
+ const mainFileName = `${functionName}_Main`;
233
+ const handlerFileName = `${functionName}_${handler}`;
234
+ const mainContent = await renderCustom(`s3/${mainTemplate}`, s3TemplateData({ action, flow, functionName }));
235
+ const handlerContent = await renderCustom(`s3/${handlerTemplate}`, s3HandlerData({ action, flow, functionName, mainFileName, handler }));
236
+ const descriptor = { functionName: `${functionName}${handler}`, handlerPath: `${handlerRoot}/${handlerFileName}.main`, roleName };
237
+ const functionYaml = type === 'wbs'
238
+ ? renderWbsFunctionYaml({ ...descriptor, routeName: tag, flowTag: flow.flowTag, flowStepName: '' })
239
+ : type === 'sqs'
240
+ ? renderSqsFunctionYaml({ ...descriptor, queueName: handlerFileName, flowTag: flow.flowTag, flowStepName: '' })
241
+ : renderInvFunctionYaml({ ...descriptor, flowTag: flow.flowTag, flowStepName: '' });
242
+ return {
243
+ artifacts: [
244
+ { path: `${source}/${mainFileName}.js`, content: mainContent },
245
+ { path: `${source}/${handlerFileName}.js`, content: handlerContent }
246
+ ],
247
+ functionYaml
248
+ };
249
+ }));
250
+ return { artifacts: emitted.flatMap(item => item.artifacts), functions: emitted.map(item => item.functionYaml) };
251
+ }
252
+
253
+ function s3TemplateData({ action, flow, functionName }) {
254
+ return action === 'CreateObject'
255
+ ? { flowTag: flow.flowTag, objectType: flow.objType?.objectType, functionName }
256
+ : action === 'CreatePreSignUrl'
257
+ ? { flowTag: flow.flowTag }
258
+ : { flowTag: flow.flowTag, functionName };
259
+ }
260
+
261
+ function s3HandlerData({ action, flow, functionName, mainFileName, handler }) {
262
+ if (action === 'CreateObject') return { functionName, handlerType: handler, route: flow.flowTag };
263
+ if (action === 'ProcessAfterUpload') return { flowTag: flow.flowTag, functionName, mainFileName, s3Bucket: flow.bucketName ?? '' };
264
+ return { functionName, handlerType: handler };
265
+ }
266
+
267
+ function startConfig(flow) {
268
+ const start = flow.flowSteps?.find(step => step.stepName?.toLowerCase() === 'start');
269
+ return start ? stepConfig(flow, start) : null;
270
+ }
271
+
272
+ function stepConfig(flow, step) {
273
+ return {
274
+ ...step,
275
+ properties: mapFields(step.properties, flow.stepProperties),
276
+ messageAttributes: mapFields(step.messageAttributes, flow.stepMessageAttributes)
277
+ };
278
+ }
279
+
280
+ function mapFields(names = [], definitions = {}) {
281
+ return names.map(name => ({ propertyName: name, ...(definitions?.[name] ?? {}) }));
282
+ }
283
+
284
+ function isS3Only(flow) {
285
+ return flow.event.length === 1 && flow.event[0] === 's3';
286
+ }
287
+
288
+ async function renderEndpointMain(flow, functionName, objects) {
289
+ return renderCustom('FlowEndpoint_Main.ejs', {
290
+ flow,
291
+ flowTag: flow.flowTag,
292
+ upperCaseFlowTag: upperFirst(flow.flowTag),
293
+ functionName,
294
+ tableName: storedCacheTableName(flow, objects)
295
+ });
296
+ }
297
+
298
+ function storedCacheTableName(flow, objects) {
299
+ if (flow.statusType !== 'storedCache') return null;
300
+ const candidates = objects.filter(object => object.objectType === flow.objType?.objectType);
301
+ const object = flow.objType?.serviceTag
302
+ ? candidates.find(object => object.serviceTag === flow.objType.serviceTag) ?? candidates.find(object => object.serviceTag === undefined)
303
+ : candidates[0];
304
+ return Object.values(object?.storageResources ?? {}).find(resource => resource?.storageType === 'dynamoDB')?.tableName ?? null;
305
+ }
306
+
307
+ async function renderStepMain(functionName) {
308
+ return renderCustom('FlowStep_Main.ejs', { functionName });
309
+ }
310
+
311
+ function renderMain(functionName) {
312
+ return `export default async function ${functionName}(_izContext, requestParams, callingFlowConfig = {}) {\n try {\n _izContext?.logger?.debug('${functionName} requestParams', requestParams);\n //(<endpointHook>)\n //(</endpointHook>)\n } catch (error) {\n _izContext?.logger?.error('${functionName} failed', error);\n throw error;\n }\n}\n`;
313
+ }
314
+
315
+ async function render(templateName, data) {
316
+ return ejs.render(await readFile(new URL(templateName, TEMPLATE_URL), 'utf8'), data);
317
+ }
318
+
319
+ async function renderDsq(templateName, data) {
320
+ return ejs.render(await readFile(new URL(templateName, DSQ_TEMPLATE_URL), 'utf8'), data);
321
+ }
322
+
323
+ async function renderCustom(templateName, data) {
324
+ return ejs.render(await readFile(new URL(templateName, CUSTOM_TEMPLATE_URL), 'utf8'), data).replace(/\n$/, '');
325
+ }
@@ -0,0 +1,22 @@
1
+ import { buildGenerationPlan } from '../../plan/buildGenerationPlan.js';
2
+ import { commitArtifacts } from '../../output/commitArtifacts.js';
3
+ import { compileProject } from '../../compile/compileProject.js';
4
+ import { loadLocalSchemaDirectory } from '../../compile/loadSchemas.js';
5
+ import { customFlowApplicationManagedPaths, emitCustomFlowApplicationArtifacts } from './emitCustomFlowApplicationArtifacts.js';
6
+ import { emitSystemWebSocketArtifacts, hasSystemWebSocket, systemWebSocketManagedPaths } from '../system/emitSystemWebSocketArtifacts.js';
7
+
8
+ export async function generateCustomFlowApplicationArtifacts(rootPath, options = {}) {
9
+ const project = compileProject({ ...options, rootPath });
10
+ const [flows, objects] = await Promise.all([
11
+ loadLocalSchemaDirectory(project, 'FlowSchemas'),
12
+ loadLocalSchemaDirectory(project, 'ObjectSchemas')
13
+ ]);
14
+ const system = await emitSystemWebSocketArtifacts(flows);
15
+ const custom = await emitCustomFlowApplicationArtifacts(flows, { systemFunctions: system.functions, objects });
16
+ const artifacts = [...system.artifacts, ...custom];
17
+ const files = await commitArtifacts(buildGenerationPlan(project, artifacts, {
18
+ managedPaths: [...systemWebSocketManagedPaths(), ...customFlowApplicationManagedPaths(flows, { includeYaml: hasSystemWebSocket(flows) })],
19
+ managedScope: 'custom-flow-application'
20
+ }));
21
+ return { project, files };
22
+ }
@@ -56,7 +56,7 @@ const { createFlowTypeConcat } = utils;
56
56
  * @returns {object} description of return value
57
57
  */
58
58
 
59
- export default async function <%- typeof functionName !== 'undefined' ? functionName : `Process${upperCaseFlowTag}` %>(
59
+ export default async function <%- typeof functionName !== 'undefined' ? functionName : upperCaseFlowTag %>(
60
60
  _izContext,
61
61
  requestParams,
62
62
  callingFlowConfig = {},
@@ -65,9 +65,9 @@ export default async function <%- typeof functionName !== 'undefined' ? function
65
65
  ) {
66
66
 
67
67
  try {
68
- _izContext.logger.debug("<%- typeof functionName !== 'undefined' ? functionName : `Process${upperCaseFlowTag}` %> _izContext", _izContext)
69
- _izContext.logger.debug("<%- typeof functionName !== 'undefined' ? functionName : `Process${upperCaseFlowTag}` %> requestParams", requestParams)
70
- _izContext.logger.debug("<%- typeof functionName !== 'undefined' ? functionName : `Process${upperCaseFlowTag}` %> callingFlowConfig", callingFlowConfig)
68
+ _izContext.logger.debug("<%- typeof functionName !== 'undefined' ? functionName : upperCaseFlowTag %> _izContext", _izContext)
69
+ _izContext.logger.debug("<%- typeof functionName !== 'undefined' ? functionName : upperCaseFlowTag %> requestParams", requestParams)
70
+ _izContext.logger.debug("<%- typeof functionName !== 'undefined' ? functionName : upperCaseFlowTag %> callingFlowConfig", callingFlowConfig)
71
71
 
72
72
  <% if (typeof flow !== 'undefined' && flow.statusType === 'storedCache') { %>
73
73
 
@@ -136,4 +136,4 @@ export default async function <%- typeof functionName !== 'undefined' ? function
136
136
  _izContext.logger.error('error WebSocketInvoke: ', err)
137
137
  throw (err)
138
138
  }
139
- }
139
+ }
@@ -57,4 +57,4 @@ export default async function <%= functionName %>(
57
57
  _izContext.logger.error('error <%= functionName %>Main: ', err)
58
58
  throw (err)
59
59
  }
60
- }
60
+ }
@@ -20,8 +20,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
20
20
  import dynamodbSharedLib from '@izara_project/izara-core-library-dynamodb';
21
21
  import snsSharedLib from '@izara_project/izara-core-library-sns';
22
22
  import { sns } from '@izara_project/izara-core-library-external-request';
23
- import { consts as generateCodeConsts } from '@izara_project/izara-core-generate-service-code';
24
- import { getNestObject } from '../../../../libs/source/GenerateCodeLibs.js';
23
+ import { consts as schemaConsts } from '@izara_project/izara-core-library-service-schemas';
24
+ import { getNestObject } from '../../../libs/source/GenerateCodeLibs.js';
25
25
 
26
26
  //(<optionalRequired>)
27
27
  //(</optionalRequired>)
@@ -73,14 +73,14 @@ export default async function confirmNewReserved(
73
73
  let confirmUsageMessage = {
74
74
  userId: userId,
75
75
  //(<optionalLimitTag>)
76
- limitTag: consts.LIMIT_TAG.uploadData,
76
+ limitTag: schemaConsts.LIMIT_TAG.uploadData,
77
77
  //(</optionalLimitTag>)
78
78
  uniqueIdentify: uniqueIdentify,
79
79
  }
80
80
 
81
81
  let sendMessageToConfirmUsage = {
82
82
  Message: JSON.stringify(confirmUsageMessage),
83
- TopicArn: await snsSharedLib.snsTopicArnByFlowSchema(_izContext, 'ConfirmUsage_In', consts.EXTERNAL_SERVICE_NAME.accountLimits)
83
+ TopicArn: await snsSharedLib.snsTopicArnByFlowSchema(_izContext, 'ConfirmUsage_In', schemaConsts.EXTERNAL_SERVICE_NAME.accountLimits)
84
84
  };
85
85
  _izContext.logger.debug("sendMessageToConfirmUsage", sendMessageToConfirmUsage);
86
86
  await sns.publishAsync(_izContext, sendMessageToConfirmUsage);
@@ -126,4 +126,4 @@ export default async function confirmNewReserved(
126
126
  _izContext.logger.debug('error ConfirmNewReservedMain: ', err)
127
127
  throw (err)
128
128
  }
129
- }
129
+ }
@@ -81,4 +81,4 @@ export const main = middleware.wrap(async (event, context) => {
81
81
  await postToConnection({ message: err.message }, connId);
82
82
  return (response.failure(err));
83
83
  }
84
- });
84
+ });
@@ -29,8 +29,8 @@ import lambdaSharedLib from '@izara_project/izara-core-library-lambda';
29
29
  import { sns } from '@izara_project/izara-core-library-external-request';
30
30
 
31
31
  import { NoRetryError } from '@izara_project/izara-core-library-core';
32
- import { consts as generateCodeConsts } from '@izara_project/izara-core-generate-service-code';
33
- const { TOPIC_NAME_GENERATE_CODE } = generateCodeConsts;
32
+ import { consts as schemaConsts } from '@izara_project/izara-core-library-service-schemas';
33
+ const { TOPIC_NAME_GENERATE_CODE } = schemaConsts;
34
34
 
35
35
  //(<optionalRequired>)
36
36
  //(</optionalRequired>)
@@ -128,4 +128,4 @@ export default async function createObject(
128
128
  _izContext.logger.error('error WebSocketInvoke: ', err)
129
129
  throw (err)
130
130
  }
131
- }
131
+ }
@@ -29,11 +29,10 @@ import { createPresignedPost } from '@aws-sdk/s3-presigned-post';
29
29
  const client = new S3Client({ region: process.env.AWS_REGION });
30
30
  import { consts } from '@izara_project/izara-middleware';
31
31
 
32
- import { postToConnection, getNestObject } from '../../../../libs/source/GenerateCodeLibs.js'
32
+ import { postToConnection, getNestObject } from '../../../libs/source/GenerateCodeLibs.js'
33
33
  import { consts as coreConsts } from '@izara_project/izara-core-library-core';
34
- import { consts as generateCodeConsts } from '@izara_project/izara-core-generate-service-code';
35
- const { EXTERNAL_SERVICE_NAME } = generateCodeConsts;
36
- import { utils } from "@izara_project/izara-core-library-service-schemas"
34
+ import { consts as schemaConsts, utils } from "@izara_project/izara-core-library-service-schemas"
35
+ const { EXTERNAL_SERVICE_NAME } = schemaConsts;
37
36
  const { createFlowTypeConcat } = utils
38
37
  //(<optionalRequired>)
39
38
  //(</optionalRequired>)
@@ -259,4 +258,4 @@ export default async function createPreSignUrl (
259
258
  _izContext.logger.error('error createPreSignUrl: ', err)
260
259
  throw (err)
261
260
  }
262
- }
261
+ }
@@ -41,16 +41,10 @@ export const main = middleware.wrap(async (event, context) => {
41
41
 
42
42
  const s3Record = event.Records[0].s3;
43
43
 
44
- // Pack the S3 trigger payload into requestParams so the main function
45
- // can decide what to do (download file, publish to SNS, invoke Lambda, etc.)
46
- const requestParams = {
47
- bucket: s3Record.bucket,
48
- object: s3Record.object,
49
- };
50
-
51
44
  const result = await <%- functionName %>(
52
45
  event._izContext,
53
- requestParams,
46
+ s3Record.bucket,
47
+ s3Record.object,
54
48
  //(<additionalParams>)
55
49
  //(</additionalParams>)
56
50
  );
@@ -63,4 +63,4 @@ export default async function processAfterUpload (
63
63
  _izContext.logger.error('error ProcessImageAfterUploadMain: ', err)
64
64
  throw (err)
65
65
  }
66
- }
66
+ }
@@ -22,12 +22,11 @@ import lambdaSharedLib from '@izara_project/izara-core-library-lambda';
22
22
  import snsSharedLib from '@izara_project/izara-core-library-sns';
23
23
  import asyncFlowSharedLib from "@izara_project/izara-core-library-asynchronous-flow";
24
24
  import { sns, webSocket } from '@izara_project/izara-core-library-external-request';
25
- import { consts as generateCodeConsts } from '@izara_project/izara-core-generate-service-code';
26
25
  import { consts as coreConsts } from '@izara_project/izara-middleware';
27
26
  import { objectHash as hash } from '@izara_project/izara-shared-core';
28
27
  import dynamodbSharedLib from '@izara_project/izara-core-library-dynamodb';
29
- import { processStaticLimit } from '../../../../libs/source/GenerateCodeLibs.js';
30
- import { utils } from "@izara_project/izara-core-library-service-schemas";
28
+ import { processStaticLimit } from '../../../libs/source/GenerateCodeLibs.js';
29
+ import { consts as schemaConsts, utils } from "@izara_project/izara-core-library-service-schemas";
31
30
  const { createFlowTypeConcat } = utils
32
31
  const { postToConnection } = webSocket;
33
32
 
@@ -77,7 +76,7 @@ export default async function reservedLimit(
77
76
  }
78
77
 
79
78
  let res = await processStaticLimit(_izContext,
80
- await lambdaSharedLib.lambdaFunctionName(_izContext, "StaticLimitProcessHdrInv", consts.EXTERNAL_SERVICE_NAME.accountLimits),
79
+ await lambdaSharedLib.lambdaFunctionName(_izContext, "StaticLimitProcessHdrInv", schemaConsts.EXTERNAL_SERVICE_NAME.accountLimits),
81
80
  payloadBeforeInvokeStaticLimit
82
81
  )
83
82
 
@@ -157,7 +156,7 @@ export default async function reservedLimit(
157
156
 
158
157
  let sendMessageToReservedDynamic = {
159
158
  Message: JSON.stringify(sendMsgReservedDynamic),
160
- TopicArn: await snsSharedLib.snsTopicArnByFlowSchema(_izContext, "ReservedDynamicUsage_In", consts.EXTERNAL_SERVICE_NAME.accountLimits)
159
+ TopicArn: await snsSharedLib.snsTopicArnByFlowSchema(_izContext, "ReservedDynamicUsage_In", schemaConsts.EXTERNAL_SERVICE_NAME.accountLimits)
161
160
  };
162
161
  _izContext.logger.debug("sendMessageToReservedDynamic", sendMessageToReservedDynamic);
163
162
  await sns.publishAsync(_izContext, sendMessageToReservedDynamic);
@@ -170,4 +169,4 @@ export default async function reservedLimit(
170
169
  _izContext.logger.error('error GetSignedUrlAccountLimit: ', err);
171
170
  throw (err)
172
171
  }
173
- }
172
+ }
@@ -0,0 +1,32 @@
1
+ import { middlewareHandler as middleware } from '@izara_project/izara-middleware';
2
+ import Logger from '@izara_project/izara-core-library-logger';
3
+ import { recordHandlerSharedLib } from '@izara_project/izara-core-library-record-handler';
4
+ import callingFlowSharedLib from '@izara_project/izara-core-library-calling-flow';
5
+
6
+ import <%- functionName %> from './<%- functionName %>_Main.js';
7
+
8
+ middleware.setValidatorSchema(recordHandlerSharedLib.baseValidatorSchema());
9
+
10
+ export const main = middleware.wrap(async event => {
11
+ try {
12
+ const recordPromises = [];
13
+ await Promise.all(event.Records.map(async record => {
14
+ await recordHandlerSharedLib.validateRecord(record, '<%- queueName %>', {}, null);
15
+ recordPromises.push(recordHandlerSharedLib.recordHandler(
16
+ record,
17
+ <%- functionName %>,
18
+ '<%- queueName %>',
19
+ [
20
+ record.body.Message.identifiers,
21
+ record.body.TopicArn,
22
+ callingFlowSharedLib.addCallingFlowToPassOnProperties(record.body.Message)
23
+ ]
24
+ ));
25
+ }));
26
+ await Promise.all(recordPromises);
27
+ return event.Records;
28
+ } catch (error) {
29
+ Logger.error('Unhandled Error, CheckTriggerCache_HdrSqs: ', error);
30
+ throw error;
31
+ }
32
+ });
@@ -0,0 +1,63 @@
1
+ import { getObjectSchema } from '@izara_project/izara-core-library-service-schemas';
2
+ import { triggeredCacheSharedLibV2 } from '@izara_project/izara-core-library-trigger-cache';
3
+
4
+ export default async function <%- functionName %>(
5
+ _izContext,
6
+ requestParams,
7
+ topicArn,
8
+ callingFlowConfig = {}
9
+ ) {
10
+ try {
11
+ _izContext.logger.debug(
12
+ '<%- functionName %> requestParams',
13
+ requestParams
14
+ );
15
+ _izContext.logger.debug(
16
+ '<%- functionName %> topicArn',
17
+ topicArn
18
+ );
19
+ _izContext.logger.debug(
20
+ '<%- functionName %> callingFlowConfig',
21
+ callingFlowConfig
22
+ );
23
+
24
+ const topicName = topicArn.split(':')[5].split('_');
25
+ const flowSchema = await getObjectSchema.getFlowSchemaS3WithCache(
26
+ _izContext,
27
+ {
28
+ flowTag: topicName[2],
29
+ serviceTag: topicName[0]
30
+ }
31
+ );
32
+
33
+ //(<checkTriggerCacheIdentifiers>)
34
+ let identifiers;
35
+ //(</checkTriggerCacheIdentifiers>)
36
+
37
+ const checkTriggerCache =
38
+ await triggeredCacheSharedLibV2.checkTriggerFlowCompleteAwaitingStepV2(
39
+ _izContext,
40
+ { serviceTag: topicName[0], flowTag: topicName[2] },
41
+ identifiers,
42
+ { flowTag: '<%- flowTag %>', serviceTag: process.env.iz_serviceTag, targetCompleteStep: process.env.iz_targetCompleteStepName }
43
+ );
44
+
45
+ _izContext.logger.debug(
46
+ '<%- functionName %> flowSchema',
47
+ flowSchema
48
+ );
49
+ _izContext.logger.debug(
50
+ '<%- functionName %> checkTriggerCache',
51
+ checkTriggerCache
52
+ );
53
+
54
+ //(<endpointHook>)
55
+ //(</endpointHook>)
56
+ } catch (error) {
57
+ _izContext.logger.error(
58
+ '<%- functionName %> failed',
59
+ error
60
+ );
61
+ throw error;
62
+ }
63
+ }