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

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 (254) hide show
  1. package/README.md +73 -11
  2. package/index.js +0 -5
  3. package/package.json +7 -6
  4. package/src/compile/compileProject.js +26 -0
  5. package/src/compile/loadSchemas.js +28 -0
  6. package/src/emit/crud/dynamicCrudFlowSchemaTemplate.js +11 -0
  7. package/src/emit/crud/emitCrudApplicationArtifacts.js +157 -0
  8. package/src/emit/crud/emitDynamicCrudFlowSchemas.js +84 -0
  9. package/src/emit/crud/generateCrudApplicationArtifacts.js +16 -0
  10. package/src/emit/crud/generateDynamicCrudFlowSchemas.js +21 -0
  11. package/src/emit/crud/loadLocalSchemaArrays.js +8 -0
  12. package/src/{codeGenerators/app/src/generatedCode/Flow/FlowObjects/templates/crud → emit/crud/templates}/CreateEndpoint_Main.ejs +1 -1
  13. package/src/{codeGenerators/app/src/generatedCode/Flow/FlowObjects/templates/crud → emit/crud/templates}/DeleteEndpoint_Main.ejs +1 -1
  14. package/src/{codeGenerators/app/src/generatedCode/Flow/FlowObjects/templates/step → emit/crud/templates}/FlowEndpointBeforeLogical_Main.ejs +2 -2
  15. package/src/emit/crud/templates/FlowEndpointComplete_Main.ejs +75 -0
  16. package/src/{codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/endpoint → emit/crud/templates}/FlowEndpoint_HdrWbs.ejs +1 -1
  17. package/src/{codeGenerators/app/src/generatedCode/ProcessLogical/templates/ProcessLogical_HdrSqs.ejs → emit/crud/templates/FlowHandler_HdrSqs.ejs} +52 -56
  18. package/src/{codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/endpoint → emit/crud/templates}/FlowMain_Wbs.ejs +1 -3
  19. package/src/emit/crud/templates/GetRangeEndpoint_Main.ejs +127 -0
  20. package/src/{codeGenerators/app/src/generatedCode/Flow/FlowObjects/templates/crud → emit/crud/templates}/UpdateEndpoint_Main.ejs +1 -1
  21. package/src/emit/custom/customFlows.js +70 -0
  22. package/src/emit/custom/emitCustomFlowApplicationArtifacts.js +308 -0
  23. package/src/emit/custom/generateCustomFlowApplicationArtifacts.js +22 -0
  24. package/src/{codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/endpoint → emit/custom/templates}/FlowEndpoint_Main.ejs +1 -1
  25. package/src/{codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/step → emit/custom/templates}/FlowStep_Main.ejs +1 -1
  26. package/src/{codeGenerators/app/src/generatedCode/Flow/FlowSchemas → emit/custom}/templates/s3/ConfirmReserved_Main.ejs +5 -5
  27. package/src/{codeGenerators/app/src/generatedCode/Flow/FlowSchemas → emit/custom}/templates/s3/CreateObject_HdrWbs.ejs +1 -1
  28. package/src/{codeGenerators/app/src/generatedCode/Flow/FlowSchemas → emit/custom}/templates/s3/CreateObject_Main.ejs +3 -3
  29. package/src/{codeGenerators/app/src/generatedCode/Flow/FlowSchemas → emit/custom}/templates/s3/CreatePreSignUrl_Main.ejs +4 -5
  30. package/src/{codeGenerators/app/src/generatedCode/Flow/FlowSchemas → emit/custom}/templates/s3/FlowHandler_HdrS3.ejs +2 -8
  31. package/src/{codeGenerators/app/src/generatedCode/Flow/FlowSchemas → emit/custom}/templates/s3/ProcessS3File_Main.ejs +1 -1
  32. package/src/{codeGenerators/app/src/generatedCode/Flow/FlowSchemas → emit/custom}/templates/s3/ReservedLimit_Main.ejs +5 -6
  33. package/src/emit/custom/templates/triggerCache/CheckTriggerCache_HdrSqs.ejs +32 -0
  34. package/src/emit/custom/templates/triggerCache/CheckTriggerCache_Main.ejs +63 -0
  35. package/src/emit/custom/templates/triggerCache/TriggerCacheComplete_Main.ejs +35 -0
  36. package/src/emit/custom/templates/triggerCache/TriggerCache_Main.ejs +16 -0
  37. package/src/emit/function/functionYamlArtifact.js +111 -0
  38. package/src/emit/rbac/emitDynamicRbacFlowSchemas.js +117 -0
  39. package/src/emit/rbac/emitRbacApplicationArtifacts.js +256 -0
  40. package/src/emit/rbac/generateCreateTargetRoleHandler.js +19 -0
  41. package/src/emit/rbac/generateDynamicRbacFlowSchemas.js +21 -0
  42. package/src/emit/rbac/rbacFlowTag.js +7 -0
  43. package/src/emit/rbac/templates/CreateTargetRole_HdrSqs.ejs +24 -0
  44. package/src/emit/rbac/templates/CreateTargetRole_Main.ejs +25 -0
  45. package/src/emit/rbac/templates/DynamicRbacFlowSchema.ejs +5 -0
  46. package/src/emit/rbac/templates/ListRbac_HdrApi.ejs +17 -0
  47. package/src/emit/rbac/templates/ListRbac_HdrSqs.ejs +13 -0
  48. package/src/emit/rbac/templates/ListRbac_Main.ejs +29 -0
  49. package/src/emit/rbac/templates/RbacMutation_Main.ejs +22 -0
  50. package/src/emit/rbac/templates/UserRbacFlow_HdrInv.ejs +10 -0
  51. package/src/emit/rbac/templates/UserRbacFlow_Main.ejs +44 -0
  52. package/src/emit/rbac/templates/UserRoleMutation_Main.ejs +33 -0
  53. package/src/emit/relationship/dynamicRelationshipFlowSchemaTemplate.js +11 -0
  54. package/src/emit/relationship/emitDynamicRelationshipFlowSchemas.js +66 -0
  55. package/src/emit/relationship/emitRelationshipApplicationArtifacts.js +147 -0
  56. package/src/emit/relationship/generateDynamicRelationshipFlowSchemas.js +23 -0
  57. package/src/emit/relationship/generateRelationshipApplicationArtifacts.js +22 -0
  58. package/src/{codeGenerators/app/src/generatedCode/Flow/FlowRelationships/templates/relationship/ProcessChangeRelationshipComplete_Main.ejs → emit/relationship/templates/ChangeRelationshipComplete_Main.ejs} +1 -1
  59. package/src/{codeGenerators/app/src/generatedCode/Flow/FlowRelationships/templates/relationship/ProcessChangeRelationship_Main.ejs → emit/relationship/templates/ChangeRelationship_Main.ejs} +10 -2
  60. package/src/{codeGenerators/app/src/generatedCode/Flow/FlowRelationships/templates/relationship/ProcessCreateRelationshipComplete_Main.ejs → emit/relationship/templates/CreateRelationshipComplete_Main.ejs} +1 -1
  61. package/src/{codeGenerators/app/src/generatedCode/Flow/FlowRelationships/templates/relationship/ProcessCreateRelationship_Main.ejs → emit/relationship/templates/CreateRelationship_Main.ejs} +1 -1
  62. package/src/{codeGenerators/app/src/generatedCode/Flow/FlowRelationships/templates/relationship/ProcessDeleteRelationshipComplete_Main.ejs → emit/relationship/templates/DeleteRelationshipComplete_Main.ejs} +1 -1
  63. package/src/{codeGenerators/app/src/generatedCode/Flow/FlowRelationships/templates/relationship/ProcessDeleteRelationship_Main.ejs → emit/relationship/templates/DeleteRelationship_Main.ejs} +1 -1
  64. package/src/emit/relationship/templates/FlowHandler_HdrApi.ejs +51 -0
  65. package/src/{codeGenerators/app/src/generatedCode/Flow/_shared/handlers → emit/relationship/templates}/FlowHandler_HdrDsq.ejs +1 -1
  66. package/src/emit/relationship/templates/FlowHandler_HdrInv.ejs +45 -0
  67. package/src/{codeGenerators/app/src/generatedCode/Flow/FlowRelationships/templates/relationship/ProcessGetRelationshipComplete_Main.ejs → emit/relationship/templates/GetRelationshipComplete_Main.ejs} +1 -1
  68. package/src/{codeGenerators/app/src/generatedCode/Flow/FlowRelationships/templates/relationship/ProcessGetRelationship_Main.ejs → emit/relationship/templates/GetRelationship_Main.ejs} +1 -1
  69. package/src/{codeGenerators/app/src/generatedCode/Flow/FlowRelationships/templates/relationship/ProcessMoveRelationship_Main.ejs → emit/relationship/templates/MoveRelationship_Main.ejs} +9 -1
  70. package/src/{codeGenerators/app/src/generatedCode/Flow/FlowRelationships/templates/relationship/ProcessUpdateRelationshipComplete_Main.ejs → emit/relationship/templates/UpdateRelationshipComplete_Main.ejs} +1 -1
  71. package/src/{codeGenerators/app/src/generatedCode/Flow/FlowRelationships/templates/relationship/ProcessUpdateRelationship_Main.ejs → emit/relationship/templates/UpdateRelationship_Main.ejs} +1 -1
  72. package/src/emit/resource/emitResourceArtifacts.js +300 -0
  73. package/src/emit/resource/generateResourceArtifacts.js +20 -0
  74. package/src/{codeGenerators/resource/sls_yaml/templates/crud → emit/resource/templates}/ResourceBeforeLogicalYaml.ejs +1 -1
  75. package/src/{codeGenerators/resource/sls_yaml/templates/crud → emit/resource/templates}/ResourceSqsYaml.ejs +6 -6
  76. package/src/{codeGenerators/app/sls_yaml → emit/resource}/templates/SharedResource_Yaml.ejs +8 -8
  77. package/src/emit/system/emitSystemWebSocketArtifacts.js +182 -0
  78. package/src/generate.js +60 -126
  79. package/src/output/commitArtifacts.js +213 -0
  80. package/src/output/mergeHooks.js +55 -0
  81. package/src/output/validateArtifacts.js +62 -0
  82. package/src/plan/buildGenerationPlan.js +50 -0
  83. package/test/core.test.js +159 -0
  84. package/test/createTargetRoleHandler.test.js +68 -0
  85. package/test/crudApplicationArtifacts.test.js +107 -0
  86. package/test/customFlowApplicationArtifacts.test.js +294 -0
  87. package/test/dynamicCrudFlowSchemas.test.js +136 -0
  88. package/test/dynamicRbacFlowSchemas.test.js +101 -0
  89. package/test/dynamicRelationshipFlowSchemas.test.js +99 -0
  90. package/test/functionYamlArtifact.test.js +34 -0
  91. package/test/intTestApi.test.js +29 -0
  92. package/test/publicApi.test.js +209 -0
  93. package/test/relationshipApplicationArtifacts.test.js +68 -0
  94. package/test/resourceArtifacts.test.js +121 -0
  95. package/jsconfig.json +0 -9
  96. package/src/__tests__/getIntTestConfig.test.js +0 -51
  97. package/src/__tests__/intTestGeneratorShared.test.cjs +0 -169
  98. package/src/__tests__/pathIntTest.test.js +0 -103
  99. package/src/codeGenerators/app/initial_setup/InitialSetupGenerator.js +0 -199
  100. package/src/codeGenerators/app/initial_setup/templates/InitialSetup_LambdaRole.ejs +0 -50
  101. package/src/codeGenerators/app/initial_setup/templates/InitialSetup_SnsService.ejs +0 -15
  102. package/src/codeGenerators/app/initial_setup/templates/InitialSetup_TableName.ejs +0 -9
  103. package/src/codeGenerators/app/sls_yaml/FindDataYamlGenerator.js +0 -23
  104. package/src/codeGenerators/app/sls_yaml/FunctionYamlGenerator.js +0 -332
  105. package/src/codeGenerators/app/sls_yaml/ProcessLogicalYamlGenerator.js +0 -21
  106. package/src/codeGenerators/app/sls_yaml/RoleNameConfigGenerator.js +0 -48
  107. package/src/codeGenerators/app/sls_yaml/SharedResourceYamlGenerator.js +0 -503
  108. package/src/codeGenerators/app/sls_yaml/__tests__/SharedResourceYamlGenerator.test.js +0 -235
  109. package/src/codeGenerators/app/sls_yaml/_policy/PolicyRegistry.js +0 -56
  110. package/src/codeGenerators/app/sls_yaml/_policy/__tests__/PolicyRegistry.test.js +0 -33
  111. package/src/codeGenerators/app/sls_yaml/renderYamlTemplate.js +0 -13
  112. package/src/codeGenerators/app/sls_yaml/templates/FindData_Yaml.ejs +0 -10
  113. package/src/codeGenerators/app/sls_yaml/templates/FunctionYaml_Api.ejs +0 -21
  114. package/src/codeGenerators/app/sls_yaml/templates/FunctionYaml_EventBridge.ejs +0 -14
  115. package/src/codeGenerators/app/sls_yaml/templates/FunctionYaml_Inv.ejs +0 -6
  116. package/src/codeGenerators/app/sls_yaml/templates/FunctionYaml_Sqs.ejs +0 -11
  117. package/src/codeGenerators/app/sls_yaml/templates/FunctionYaml_Wbs.ejs +0 -11
  118. package/src/codeGenerators/app/sls_yaml/templates/ProcessLogical_Yaml.ejs +0 -32
  119. package/src/codeGenerators/app/sls_yaml/templates/RoleNameConfig_Yaml.ejs +0 -5
  120. package/src/codeGenerators/app/src/generatedCode/FindData/FindDataGenerator.js +0 -238
  121. package/src/codeGenerators/app/src/generatedCode/FindData/templates/FindData_HdrSqs.ejs +0 -87
  122. package/src/codeGenerators/app/src/generatedCode/FindData/templates/FindData_Main.ejs +0 -108
  123. package/src/codeGenerators/app/src/generatedCode/FindData/templates/GetByStorage/getByDynamo.ejs +0 -32
  124. package/src/codeGenerators/app/src/generatedCode/FindData/templates/GetByStorage/getByGraph.ejs +0 -87
  125. package/src/codeGenerators/app/src/generatedCode/Flow/FlowObjects/.gitkeep +0 -0
  126. package/src/codeGenerators/app/src/generatedCode/Flow/FlowObjects/EndpointsGenerator.js +0 -120
  127. package/src/codeGenerators/app/src/generatedCode/Flow/FlowObjects/templates/step/FlowEndpointComplete_Main.ejs +0 -313
  128. package/src/codeGenerators/app/src/generatedCode/Flow/FlowRbac/RbacFlowGenerator.js +0 -116
  129. package/src/codeGenerators/app/src/generatedCode/Flow/FlowRbac/templates/rbac/CreateRolePermissions.ejs +0 -135
  130. package/src/codeGenerators/app/src/generatedCode/Flow/FlowRbac/templates/rbac/CreateTargetRole.ejs +0 -131
  131. package/src/codeGenerators/app/src/generatedCode/Flow/FlowRbac/templates/rbac/CreateUserRole.ejs +0 -150
  132. package/src/codeGenerators/app/src/generatedCode/Flow/FlowRbac/templates/rbac/DeleteRolePermissions.ejs +0 -132
  133. package/src/codeGenerators/app/src/generatedCode/Flow/FlowRbac/templates/rbac/DeleteTargetRole.ejs +0 -132
  134. package/src/codeGenerators/app/src/generatedCode/Flow/FlowRbac/templates/rbac/DeleteUserFromRole.ejs +0 -150
  135. package/src/codeGenerators/app/src/generatedCode/Flow/FlowRbac/templates/rbac/FlowRbac_Main.ejs +0 -252
  136. package/src/codeGenerators/app/src/generatedCode/Flow/FlowRbac/templates/rbac/ListRolePermissions.ejs +0 -120
  137. package/src/codeGenerators/app/src/generatedCode/Flow/FlowRbac/templates/rbac/ListTargetRole.ejs +0 -122
  138. package/src/codeGenerators/app/src/generatedCode/Flow/FlowRbac/templates/rbac/ListUserInRoles.ejs +0 -117
  139. package/src/codeGenerators/app/src/generatedCode/Flow/FlowRelationships/RelationshipFlowGenerator.js +0 -148
  140. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/.gitkeep +0 -0
  141. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/StatusFieldGenerator.js +0 -109
  142. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/WebSocketGenerator.js +0 -122
  143. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/endpoint/FlowEntryPoint_Main.ejs +0 -38
  144. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/statusField/CompleteStatusFieldSns_Yaml.ejs +0 -52
  145. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/statusField/CompleteStatusField_HdrSqs.ejs +0 -84
  146. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/statusField/CompleteStatusField_Main.ejs +0 -78
  147. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/step/plugIns/FlowStep_ByConfig_Awaiting_Main.ejs +0 -123
  148. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/step/plugIns/FlowStep_ByConfig_Paginated_Main.ejs +0 -59
  149. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/step/plugIns/FlowStep_PlugIn_Main.ejs +0 -72
  150. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/step/plugIns/FlowStep_RecievePlugIn_Main.ejs +0 -76
  151. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/step/plugIns/templateAwaitingStep.ejs +0 -41
  152. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/step/plugIns/templateSendPlugin.ejs +0 -18
  153. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/webSocket/ProcessWebSocketFlow_Yaml.ejs +0 -26
  154. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/webSocket/ProcessWebSocketSub_Yaml.ejs +0 -7
  155. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/webSocket/ProcessWebSocket_HdrSqs.ejs +0 -66
  156. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/webSocket/ProcessWebSocket_Main.ejs +0 -115
  157. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/webSocket/ProcessWebSocket_Yaml.ejs +0 -36
  158. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/webSocket/WebSocketConnect_Main.ejs +0 -52
  159. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/webSocket/WebSocketConnect_Yaml.ejs +0 -13
  160. package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/webSocket/WebSocketDynamoDb_Yaml.ejs +0 -28
  161. package/src/codeGenerators/app/src/generatedCode/Flow/_shared/events/BaseDsqHandler.js +0 -63
  162. package/src/codeGenerators/app/src/generatedCode/Flow/_shared/events/BaseSqsHandler.js +0 -66
  163. package/src/codeGenerators/app/src/generatedCode/Flow/_shared/events/__tests__/BaseDsqHandler.test.js +0 -94
  164. package/src/codeGenerators/app/src/generatedCode/Flow/_shared/events/dsq.js +0 -5
  165. package/src/codeGenerators/app/src/generatedCode/Flow/_shared/events/eventBridge.js +0 -33
  166. package/src/codeGenerators/app/src/generatedCode/Flow/_shared/events/extTopic.js +0 -6
  167. package/src/codeGenerators/app/src/generatedCode/Flow/_shared/events/lambdaSyncApi.js +0 -51
  168. package/src/codeGenerators/app/src/generatedCode/Flow/_shared/events/lambdaSyncInv.js +0 -51
  169. package/src/codeGenerators/app/src/generatedCode/Flow/_shared/events/ownTopic.js +0 -54
  170. package/src/codeGenerators/app/src/generatedCode/Flow/_shared/events/registry.js +0 -17
  171. package/src/codeGenerators/app/src/generatedCode/Flow/_shared/events/s3.js +0 -56
  172. package/src/codeGenerators/app/src/generatedCode/Flow/_shared/events/s3Components/ConfirmAfterUploadS3Generator.js +0 -46
  173. package/src/codeGenerators/app/src/generatedCode/Flow/_shared/events/s3Components/CreateObjectGenerator.js +0 -50
  174. package/src/codeGenerators/app/src/generatedCode/Flow/_shared/events/s3Components/CreatePreSignUrlGenerator.js +0 -48
  175. package/src/codeGenerators/app/src/generatedCode/Flow/_shared/events/s3Components/ProcessAfterUploadS3Generator.js +0 -49
  176. package/src/codeGenerators/app/src/generatedCode/Flow/_shared/events/s3Components/ReservedLimitGenerator.js +0 -47
  177. package/src/codeGenerators/app/src/generatedCode/Flow/_shared/shared/eventTypes.js +0 -23
  178. package/src/codeGenerators/app/src/generatedCode/Flow/_shared/shared/flowClassifier.js +0 -50
  179. package/src/codeGenerators/app/src/generatedCode/Flow/_shared/shared/flowEntryPointBase.js +0 -106
  180. package/src/codeGenerators/app/src/generatedCode/Flow/_shared/shared/flowMainFunctionBase.js +0 -172
  181. package/src/codeGenerators/app/src/generatedCode/Flow/_shared/shared/flowNaming.js +0 -37
  182. package/src/codeGenerators/app/src/generatedCode/Flow/_shared/shared/flowSelection.js +0 -19
  183. package/src/codeGenerators/app/src/generatedCode/Flow/_shared/shared/flowStepBase.js +0 -235
  184. package/src/codeGenerators/app/src/generatedCode/Flow/_shared/shared/flowStepNormalizer.js +0 -75
  185. package/src/codeGenerators/app/src/generatedCode/Flow/_shared/shared/flowValidator.js +0 -267
  186. package/src/codeGenerators/app/src/generatedCode/Flow/_shared/shared/propertyNormalizer.js +0 -18
  187. package/src/codeGenerators/app/src/generatedCode/Flow/_shared/shared/registry.js +0 -7
  188. package/src/codeGenerators/app/src/generatedCode/Flow/_shared/shared/roleNameDetection.js +0 -49
  189. package/src/codeGenerators/app/src/generatedCode/Flow/_shared/shared/triggerCacheBase.js +0 -177
  190. package/src/codeGenerators/app/src/generatedCode/Flow/_shared/triggerCache/CheckTriggerCache_HdrSqs.ejs +0 -89
  191. package/src/codeGenerators/app/src/generatedCode/Flow/_shared/triggerCache/CheckTriggerCache_Main.ejs +0 -83
  192. package/src/codeGenerators/app/src/generatedCode/Flow/_shared/triggerCache/ProcessTriggerCache_HdrSqs.ejs +0 -103
  193. package/src/codeGenerators/app/src/generatedCode/Flow/_shared/triggerCache/ProcessTriggerCache_Main.ejs +0 -58
  194. package/src/codeGenerators/app/src/generatedCode/Flow/_shared/triggerCache/TriggerCacheComplete_HdrDsq.ejs +0 -104
  195. package/src/codeGenerators/app/src/generatedCode/Flow/_shared/triggerCache/TriggerCacheComplete_HdrSqs.ejs +0 -88
  196. package/src/codeGenerators/app/src/generatedCode/Flow/_shared/triggerCache/TriggerCacheComplete_Main.ejs +0 -80
  197. package/src/codeGenerators/app/src/generatedCode/Flow/_shared/triggerCache/TriggerCacheQueue_Yaml.ejs +0 -36
  198. package/src/codeGenerators/app/src/generatedCode/Flow/_shared/yaml/SharedFunctionSqs_Yaml.ejs +0 -13
  199. package/src/codeGenerators/app/src/generatedCode/ProcessLogical/ProcessLogicalGenerator.js +0 -29
  200. package/src/codeGenerators/app/src/generatedCode/ProcessLogical/templates/PaginateProcessLogical_HdrDsq.ejs +0 -177
  201. package/src/codeGenerators/app/src/generatedCode/ProcessLogical/templates/PaginateProcessLogical_HdrSqs.ejs +0 -155
  202. package/src/codeGenerators/app/src/generatedCode/ProcessLogical/templates/PaginateProcessLogical_Main.ejs +0 -268
  203. package/src/codeGenerators/app/src/generatedCode/ProcessLogical/templates/ProcessLogical_Main.ejs +0 -450
  204. package/src/codeGenerators/app/src/generatedCode/SystemFlowSchemas/RegisterGenerator.js +0 -149
  205. package/src/codeGenerators/app/src/generatedCode/SystemFlowSchemas/templates/register/RegisterComplete_HdrSqs.ejs +0 -85
  206. package/src/codeGenerators/app/src/generatedCode/SystemFlowSchemas/templates/register/RegisterComplete_Main.ejs +0 -176
  207. package/src/codeGenerators/app/src/generatedCode/SystemFlowSchemas/templates/register/Register_HdrWbs.ejs +0 -80
  208. package/src/codeGenerators/app/src/generatedCode/SystemFlowSchemas/templates/register/Register_Main.ejs +0 -164
  209. package/src/codeGenerators/app/src/generatedCode/libs/ConstsGenerator.js +0 -28
  210. package/src/codeGenerators/app/src/generatedCode/libs/GenerateCodeLibsGenerator.js +0 -28
  211. package/src/codeGenerators/app/src/generatedCode/libs/templates/Consts.ejs +0 -448
  212. package/src/codeGenerators/app/src/generatedCode/libs/templates/GenerateCodeLibs.ejs +0 -124
  213. package/src/codeGenerators/resource/sls_yaml/DynamoDBGenerator.js +0 -87
  214. package/src/codeGenerators/resource/sls_yaml/FlowOutGenerator.js +0 -70
  215. package/src/codeGenerators/resource/sls_yaml/FlowResourceYamlGenerator.js +0 -182
  216. package/src/core/renderTemplateFile.js +0 -22
  217. package/src/core/validate.js +0 -165
  218. package/src/generateCode.js +0 -357
  219. package/src/generateSchema.js +0 -123
  220. package/src/parsers/flowSchemaParser.js +0 -112
  221. package/src/parsers/objectSchemaParser.js +0 -39
  222. package/src/parsers/relationshipSchemaParser.js +0 -51
  223. package/src/schemaGenerators/app/src/schemas/FlowSchemas/FlowSchemaGenerator.js +0 -107
  224. package/src/schemaGenerators/app/src/schemas/FlowSchemas/RbacFlowSchemaGenerator.js +0 -98
  225. package/src/schemaGenerators/app/src/schemas/FlowSchemas/RelationshipFlowSchemaGenerator.js +0 -89
  226. package/src/schemaGenerators/app/src/schemas/FlowSchemas/templates/DynamicFlowSchemaTemplate.ejs +0 -41
  227. package/src/schemaGenerators/app/src/schemas/FlowSchemas/templates/DynamicRbacFlowSchemaTemplate.ejs +0 -20
  228. package/src/schemaGenerators/app/src/schemas/FlowSchemas/templates/RelationshipFlowSchemaTemplate.ejs +0 -33
  229. package/src/schemaGenerators/app/src/schemas/FlowSchemas/templates/UserRbacFlowSchemaTemplate.ejs +0 -22
  230. package/src/schemaGenerators/app/src/schemas/ObjectSchemas/AttributeTreeSchemaGenerator.js +0 -124
  231. package/src/schemaGenerators/app/src/schemas/ObjectSchemas/PropertyValueSchemaGenerator.js +0 -119
  232. package/src/schemaGenerators/app/src/schemas/ObjectSchemas/templates/DynamicAttributeTreeManagerSchemaTemplate.ejs +0 -14
  233. package/src/schemaGenerators/app/src/schemas/ObjectSchemas/templates/DynamicAttributeTreeStandardSchemaTemplate.ejs +0 -13
  234. package/src/schemaGenerators/app/src/schemas/ObjectSchemas/templates/DynamicPropertyValueSchemaTemplate.ejs +0 -15
  235. package/src/schemaGenerators/app/src/schemas/RelationshipSchemas/AttributeTreeRelationshipSchemaGenerator.js +0 -109
  236. package/src/schemaGenerators/app/src/schemas/RelationshipSchemas/PropertyValueRelationshipSchemaGenerator.js +0 -103
  237. package/src/schemaGenerators/app/src/schemas/RelationshipSchemas/__tests__/relationshipSchemaHelpers.test.js +0 -38
  238. package/src/schemaGenerators/app/src/schemas/RelationshipSchemas/relationshipSchemaHelpers.js +0 -40
  239. package/src/schemaGenerators/app/src/schemas/RelationshipSchemas/templates/DynamicAttributeTreeRelationshipSchemaTemplate.ejs +0 -7
  240. package/src/schemaGenerators/app/src/schemas/RelationshipSchemas/templates/DynamicPropertyValueRelationshipSchemaTemplate.ejs +0 -7
  241. package/src/schemaGenerators/app/src/schemas/SystemTextSchemas/SystemTextGenerator.js +0 -102
  242. package/src/schemaGenerators/app/src/schemas/SystemTextSchemas/templates/SystemText_Template.ejs +0 -10
  243. /package/src/{codeGenerators/app/src/generatedCode/Flow/_shared/handlers → emit/crud/templates}/FlowHandler_HdrApi.ejs +0 -0
  244. /package/src/{codeGenerators/app/src/generatedCode/Flow/_shared/handlers → emit/crud/templates}/FlowHandler_HdrInv.ejs +0 -0
  245. /package/src/{codeGenerators/app/src/generatedCode/Flow/FlowObjects/templates/crud → emit/crud/templates}/GetEndpoint_Main.ejs +0 -0
  246. /package/src/{codeGenerators/app/src/generatedCode/Flow/FlowSchemas → emit/custom}/templates/s3/ConfirmReserved_HdrSqs.ejs +0 -0
  247. /package/src/{codeGenerators/app/src/generatedCode/Flow/FlowSchemas → emit/custom}/templates/s3/CreatePreSignUrl_HdrSqs.ejs +0 -0
  248. /package/src/{codeGenerators/app/src/generatedCode/Flow/FlowSchemas → emit/custom}/templates/s3/ReservedLimit_HdrSqs.ejs +0 -0
  249. /package/src/{codeGenerators/app/src/generatedCode/Flow/_shared/handlers → emit/relationship/templates}/FlowHandler_HdrSqs.ejs +0 -0
  250. /package/src/{codeGenerators/app/src/generatedCode/Flow/FlowRelationships/templates/relationship/ProcessMoveRelationshipComplete_Main.ejs → emit/relationship/templates/MoveRelationshipComplete_Main.ejs} +0 -0
  251. /package/src/{codeGenerators/resource/sls_yaml → emit/resource}/templates/DynamoDBTable_Yaml.ejs +0 -0
  252. /package/src/{codeGenerators/resource/sls_yaml → emit/resource}/templates/FlowOut_Yaml.ejs +0 -0
  253. /package/src/{codeGenerators/resource/sls_yaml/templates/crud → emit/resource/templates}/ResourceYaml.ejs +0 -0
  254. /package/src/{codeGenerators/resource/sls_yaml → emit/resource}/templates/SystemDynamoDB_Yaml.ejs +0 -0
package/README.md CHANGED
@@ -1,15 +1,77 @@
1
- # izara-izara-core-generate-service-code
1
+ # IzaraCore-SupportServices-GenerateServiceCodeV2
2
2
 
3
- # update version
4
- - commit code first
5
- npm version patch || npm version minor || npm version major
3
+ New implementation of the schema-driven service generator. The legacy
4
+ GenerateServiceCode repository remains the behavior oracle during migration.
6
5
 
7
- # can also push to repo ..
8
- git push
9
- # make sure commits look correct
6
+ The first V2 seam is deliberately small:
10
7
 
11
- # push to npm
12
- npm publish
8
+ ```text
9
+ GenerationRequest -> ProjectModel -> GenerationPlan -> Artifact[] -> committed files
10
+ ```
13
11
 
14
- # update project that uses this package
15
- npm update @izara_project/izara-core-generate-service-code
12
+ `test-lib-generateCode` now points its local dependency at this checkout. Its
13
+ V2 acceptance suites use only `generate(rootPath, options)`. Legacy golden
14
+ comparison remains an oracle review: generation and artifact paths pass, while
15
+ content differences are not accepted automatically.
16
+
17
+ ## Current Slice
18
+
19
+ `generate(rootPath, options)` is the only public entrypoint. It loads
20
+ the three schema directories once, emits every currently migrated schema,
21
+ application, and resource slice, then commits all artifacts in one transaction
22
+ and returns one `GenerationResult`. Managed artifacts retain their existing
23
+ slice ownership, so stale files are cleaned without deleting legacy-owned
24
+ output.
25
+
26
+ `generate()` rejects invalid project/schema/artifact input before it commits.
27
+ If staging or replacing an output target fails (including a directory or
28
+ symlink where a generated file belongs), it restores every affected artifact
29
+ and manifest from the same transaction; callers receive the original error.
30
+
31
+ ## Current Cutover Boundary
32
+
33
+ V2 is generator-only for the current migration. `test-lib-generateCode` is
34
+ the approved V2 consumer and calls the supported `generate()` API. Deployed
35
+ services continue to use the legacy 1.x package for runtime imports; V2 does
36
+ not provide legacy runtime exports such as `generateCode`, `utils`, `consts`,
37
+ or `libs`.
38
+
39
+ Do not replace the legacy package in a deployed service with V2 until a
40
+ separate runtime migration removes those generated-code imports and verifies
41
+ the resulting service behavior. The legacy repository is read-only and
42
+ non-runtime now. After the first successful V2 production deployment, 90 days
43
+ and two release cycles must both complete before it is archived as a protected,
44
+ read-only Git repository. Archive retains its tags, history, and fixtures; it
45
+ does not delete the repository.
46
+
47
+ Generated function YAML preserves `FunctionSetting` hook blocks across
48
+ regeneration and rollback. Completion SQS handlers retain the established
49
+ `callingFlow` filter contract.
50
+
51
+ Internally, the custom-flow emitter owns fixture-level application artifacts
52
+ for `eventBridge`, `ownTopic`, `extTopic`, `lambdaSyncInv`, `lambdaSyncApi`,
53
+ and S3's five entry handlers. The Phase 7 contract is artifact-level (paths,
54
+ JavaScript syntax, YAML and resource/IAM wiring), not an end-to-end invocation
55
+ contract.
56
+
57
+ ## Architecture Status
58
+
59
+ The implemented V2 layout makes the pipeline ownership explicit:
60
+
61
+ ```text
62
+ src/compile/ request and local schema loading
63
+ src/plan/ GenerationPlan construction
64
+ src/emit/ schema, application, function, resource, and system emitters
65
+ src/output/ artifact validation, hook merge, and transaction commit
66
+ ```
67
+
68
+ `src/generate.js` remains the high-level orchestration entrypoint. Emitter
69
+ domains and their templates stay together beneath `src/emit/`; no pass-through
70
+ modules were added only to mirror the proposed diagram. Internal modules are
71
+ not part of the package API.
72
+
73
+ ## Development
74
+
75
+ ```bash
76
+ npm test
77
+ ```
package/index.js CHANGED
@@ -16,17 +16,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
16
16
  */
17
17
 
18
18
  import { generate } from './src/generate.js';
19
- import { generateCode } from './src/generateCode.js';
20
- import { generateSchema } from './src/generateSchema.js';
21
19
  import { generateIntTest } from './src/generateIntTest.js';
22
20
  import { generateResourceIntTest } from './src/generateResourceIntTest.js';
23
21
 
24
22
  export {
25
23
  // High-level API (recommended for consumers) — wires legacy Logger+validateLocalSchema
26
24
  generate,
27
- // Main generators (low-level)
28
- generateCode,
29
- generateSchema,
30
25
  // IntTest generators (Result-Driven: no createSource/libs dependencies)
31
26
  generateIntTest,
32
27
  generateResourceIntTest
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@izara_project/izara-core-generate-service-code",
3
- "version": "1.0.65",
3
+ "version": "1.0.66",
4
4
  "description": "Code for locally generating per service files",
5
5
  "homepage": "https://bitbucket.org/izara-core-support-services/izara-core-support-services-generate-service-code#readme",
6
6
  "repository": {
@@ -11,6 +11,7 @@
11
11
  "author": "Sven Mason <thebarbariansven@gmail.com>",
12
12
  "type": "module",
13
13
  "main": "index.js",
14
+ "exports": "./index.js",
14
15
  "scripts": {
15
16
  "test": "jest"
16
17
  },
@@ -19,9 +20,9 @@
19
20
  },
20
21
  "dependencies": {
21
22
  "@izara_project/izara-core-library-core": "^1.0.32",
22
- "@izara_project/izara-core-library-logger": "^1.0.9",
23
- "@izara_project/izara-shared-core": "^1.0.12",
24
- "ejs": "^5.0.1",
23
+ "@izara_project/izara-core-library-logger": "^1.0.11",
24
+ "@izara_project/izara-shared-core": "^1.0.13",
25
+ "ejs": "^6.0.1",
25
26
  "js-beautify": "^2.0.3",
26
27
  "yaml": "^2.9.0",
27
28
  "@izara_project/izara-property-nodes": "^1.0.16",
@@ -32,8 +33,8 @@
32
33
  "@izara_project/izara-shared-service-schemas": "^1.0.65"
33
34
  },
34
35
  "devDependencies": {
35
- "@izara_project/izara-core-library-service-schemas": "^1.0.157",
36
- "@izara_project/izara-shared-service-schemas": "^1.0.65",
36
+ "@izara_project/izara-core-library-service-schemas": "^1.0.158",
37
+ "@izara_project/izara-shared-service-schemas": "^1.0.66",
37
38
  "jest": "^30.4.2"
38
39
  }
39
40
  }
@@ -0,0 +1,26 @@
1
+ import { join, resolve } from 'node:path';
2
+
3
+ export function compileProject(request = {}) {
4
+ if (!isNonEmptyString(request.rootPath)) {
5
+ throw new TypeError('GenerationRequest.rootPath must be a non-empty string');
6
+ }
7
+
8
+ const rootPath = resolve(request.rootPath);
9
+ const outputPath = resolve(request.outputPath ?? rootPath);
10
+ const configPath = resolve(
11
+ request.configPath ?? join(rootPath, 'config', 'serverless.config.yml')
12
+ );
13
+
14
+ return Object.freeze({
15
+ rootPath,
16
+ outputPath,
17
+ configPath,
18
+ schemaRoot: join(rootPath, 'app', 'src', 'schemas'),
19
+ serviceTag: request.serviceTag,
20
+ schemaTemplateConfig: request.schemaTemplateConfig ?? []
21
+ });
22
+ }
23
+
24
+ function isNonEmptyString(value) {
25
+ return typeof value === 'string' && value.trim() !== '';
26
+ }
@@ -0,0 +1,28 @@
1
+ import { readdir, stat } from 'node:fs/promises';
2
+ import { join } from 'node:path';
3
+ import { pathToFileURL } from 'node:url';
4
+
5
+ export async function loadLocalSchemaDirectory(project, directoryName) {
6
+ const directoryPath = join(project.schemaRoot, directoryName);
7
+ let entries;
8
+ try {
9
+ entries = await readdir(directoryPath, { withFileTypes: true });
10
+ } catch (error) {
11
+ if (error.code === 'ENOENT') {
12
+ return [];
13
+ }
14
+ throw error;
15
+ }
16
+
17
+ const schemas = [];
18
+ for (const entry of entries.filter(entry => entry.isFile() && entry.name.endsWith('.js')).sort((a, b) => a.name.localeCompare(b.name))) {
19
+ const filePath = join(directoryPath, entry.name);
20
+ const details = await stat(filePath);
21
+ const module = await import(`${pathToFileURL(filePath).href}?schemaVersion=${details.mtimeMs}-${details.size}`);
22
+ if (!module.default || typeof module.default !== 'object') {
23
+ throw new TypeError(`Schema module must default-export an object or array: ${filePath}`);
24
+ }
25
+ schemas.push(...(Array.isArray(module.default) ? module.default : [module.default]));
26
+ }
27
+ return schemas;
28
+ }
@@ -0,0 +1,11 @@
1
+ export function renderDynamicCrudFlowSchema(action, flow) {
2
+ return [
3
+ '/**',
4
+ ' * GENERATED DYNAMIC FLOW SCHEMA',
5
+ ` * Action: ${action}`,
6
+ ' * Description: Handles dynamic CRUD for all allowed ObjectTypes via SQS/DSQ',
7
+ ' */',
8
+ `export default ${JSON.stringify(flow, null, 2)};`,
9
+ ''
10
+ ].join('\n');
11
+ }
@@ -0,0 +1,157 @@
1
+ import ejs from 'ejs';
2
+ import { readFile } from 'node:fs/promises';
3
+
4
+ import {
5
+ renderApiFunctionYaml,
6
+ renderInvFunctionYaml,
7
+ renderSqsFunctionYaml,
8
+ renderWbsFunctionYaml
9
+ } from '../function/functionYamlArtifact.js';
10
+
11
+ const ACTIONS = ['Create', 'Update', 'Delete', 'Get'];
12
+ const YAML_PATH = 'app/sls_yaml/generatedCode/source/flow-objects.yml';
13
+ const TEMPLATE_URL = new URL('./templates/', import.meta.url);
14
+
15
+ export async function emitCrudApplicationArtifacts({ objects, flows = [], serviceTag }) {
16
+ if (!Array.isArray(objects) || !Array.isArray(flows)) {
17
+ throw new TypeError('objects and flows must be arrays');
18
+ }
19
+ if (!objects.some(isCrudObject)) return [];
20
+
21
+ const handlers = await Promise.all(ACTIONS.map(action => emitAction(action, objects, flows, serviceTag)));
22
+ return [
23
+ ...handlers.flatMap(handler => handler.artifacts),
24
+ {
25
+ path: YAML_PATH,
26
+ content: handlers.flatMap(handler => handler.functions).map(renderFunction).join('\n')
27
+ }
28
+ ];
29
+ }
30
+
31
+ export function crudApplicationManagedPaths() {
32
+ return [
33
+ ...ACTIONS.flatMap(action => {
34
+ const source = `app/src/generatedCode/FlowObjects/${action}/source`;
35
+ const paths = [`${source}/${action}_Main.js`];
36
+ if (action === 'Get') {
37
+ paths.push(`${source}/Get_HdrInv.js`, `${source}/Get_HdrApi.js`);
38
+ paths.push(`${source}/GetRange_Main.js`, `${source}/GetRange_HdrApi.js`);
39
+ } else {
40
+ paths.push(
41
+ `${source}/${action}_HdrSqs.js`,
42
+ `${source}/${action}_WbsMain.js`,
43
+ `${source}/${action}_HdrWbs.js`,
44
+ `${source}/${action}BeforeLogical_Main.js`,
45
+ `${source}/${action}BeforeLogical_HdrSqs.js`
46
+ );
47
+ paths.push(`${source}/${action}Complete_Main.js`, `${source}/${action}Complete_HdrSqs.js`);
48
+ }
49
+ return paths;
50
+ }),
51
+ YAML_PATH
52
+ ];
53
+ }
54
+
55
+ async function emitAction(action, objects, flows, serviceTag) {
56
+ const source = `app/src/generatedCode/FlowObjects/${action}/source`;
57
+ const handlerRoot = `src/generatedCode/FlowObjects/${action}/source`;
58
+ const generateCode = flows
59
+ .filter(flow => flow?.generatedCodeConfig?.generatedCodeTag?.toLowerCase() === action.toLowerCase())
60
+ .map(flow => ({ ...flow.generatedCodeConfig, flowTag: flow.flowTag }));
61
+ const mainFileName = `${action}_Main`;
62
+ const shared = {
63
+ flowTag: action,
64
+ upperCaseFlowTag: action,
65
+ topicArn: `${action}_In`,
66
+ generateCode,
67
+ flow: null,
68
+ flowStepName: '',
69
+ startConfig: null
70
+ };
71
+ const artifacts = [{
72
+ path: `${source}/${mainFileName}.js`,
73
+ content: await render(`${action}Endpoint_Main.ejs`, shared)
74
+ }];
75
+
76
+ if (action === 'Get') {
77
+ artifacts.push(
78
+ { path: `${source}/Get_HdrInv.js`, content: await render('FlowHandler_HdrInv.ejs', { ...shared, mainFileName, functionName: 'Get', queueName: 'GetHdrInv' }) },
79
+ { path: `${source}/Get_HdrApi.js`, content: await render('FlowHandler_HdrApi.ejs', { ...shared, mainFileName, functionName: 'Get', queueName: 'GetHdrApi' }) },
80
+ { path: `${source}/GetRange_Main.js`, content: await render('GetRangeEndpoint_Main.ejs', { ...shared, mainFileName: 'GetRange_Main', functionName: 'GetRange' }) },
81
+ { path: `${source}/GetRange_HdrApi.js`, content: await render('FlowHandler_HdrApi.ejs', { ...shared, mainFileName: 'GetRange_Main', functionName: 'GetRange', queueName: 'GetRangeHdrApi' }) }
82
+ );
83
+ return {
84
+ artifacts,
85
+ functions: [
86
+ { type: 'inv', functionName: 'GetHdrInv', handlerPath: `${handlerRoot}/Get_HdrInv.main`, roleName: 'FlowObjectsRole' },
87
+ {
88
+ type: 'api',
89
+ functionName: 'GetHdrApi',
90
+ handlerPath: `${handlerRoot}/Get_HdrApi.main`,
91
+ roleName: 'FlowObjectsRole',
92
+ routes: objects.filter(isCrudObject).map(object => ({
93
+ path: `/${serviceTag ?? '${self:custom.iz_serviceName}'}/${object.objectType}/get`,
94
+ upperName: upperFirst(object.objectType)
95
+ }))
96
+ },
97
+ {
98
+ type: 'api',
99
+ functionName: 'GetRangeHdrApi',
100
+ handlerPath: `${handlerRoot}/GetRange_HdrApi.main`,
101
+ roleName: 'FlowObjectsRole',
102
+ routes: objects.filter(isCrudObject)
103
+ .filter(object => object.identifiers && object.identifiers.some(i => i.type === 'sortKey'))
104
+ .map(object => ({
105
+ path: `/${serviceTag ?? '${self:custom.iz_serviceName}'}/${object.objectType}/getRange`,
106
+ upperName: upperFirst(object.objectType)
107
+ }))
108
+ }
109
+ ]
110
+ };
111
+ }
112
+
113
+ artifacts.push(
114
+ { path: `${source}/${action}_HdrSqs.js`, content: await render('FlowHandler_HdrSqs.ejs', { ...shared, mainFileName, functionName: action, queueName: `${action}HdrSqs` }) },
115
+ { path: `${source}/${action}_WbsMain.js`, content: await render('FlowMain_Wbs.ejs', { ...shared, functionName: action }) },
116
+ { path: `${source}/${action}_HdrWbs.js`, content: await render('FlowEndpoint_HdrWbs.ejs', { ...shared, mainFileName: `${action}_WbsMain`, functionName: action, route: action }) }
117
+ );
118
+ const functions = [
119
+ { type: 'wbs', functionName: `${action}HdrWbs`, handlerPath: `${handlerRoot}/${action}_HdrWbs.main`, roleName: 'FlowObjectsRole', routeName: action },
120
+ { type: 'sqs', functionName: `${action}HdrSqs`, handlerPath: `${handlerRoot}/${action}_HdrSqs.main`, roleName: 'FlowObjectsRole', queueName: `${action}HdrSqs` }
121
+ ];
122
+ const complete = `${action}Complete`;
123
+ artifacts.push(
124
+ { path: `${source}/${complete}_Main.js`, content: await render('FlowEndpointComplete_Main.ejs', { action }) },
125
+ { path: `${source}/${complete}_HdrSqs.js`, content: await render('FlowHandler_HdrSqs.ejs', { ...shared, mainFileName: `${complete}_Main`, functionName: complete, queueName: `${action}CompleteHdrSqs` }) }
126
+ );
127
+ functions.push({ type: 'sqs', functionName: `${action}CompleteHdrSqs`, handlerPath: `${handlerRoot}/${complete}_HdrSqs.main`, roleName: 'FlowObjectsRole', queueName: `${action}CompleteHdrSqs` });
128
+ if (generateCode.some(config => config.codeHookTag === 'beforeLogical')) {
129
+ const beforeMain = `${action}BeforeLogical_Main`;
130
+ artifacts.push(
131
+ { path: `${source}/${beforeMain}.js`, content: await render('FlowEndpointBeforeLogical_Main.ejs', shared) },
132
+ { path: `${source}/${action}BeforeLogical_HdrSqs.js`, content: await render('FlowHandler_HdrSqs.ejs', { ...shared, mainFileName: beforeMain, functionName: `${action}BeforeLogicalMain`, queueName: `${action}BeforeLogicalHdrSqs` }) }
133
+ );
134
+ functions.push({ type: 'sqs', functionName: `${action}BeforeLogicalHdrSqs`, handlerPath: `${handlerRoot}/${action}BeforeLogical_HdrSqs.main`, roleName: 'FlowObjectsRole', queueName: `${action}BeforeLogicalHdrSqs` });
135
+ }
136
+ return { artifacts, functions };
137
+ }
138
+
139
+ function isCrudObject(object) {
140
+ return object?.generatedBy === 'userGenerated' || object?.generatedBy === 'systemGenerated';
141
+ }
142
+
143
+ function upperFirst(value) {
144
+ return value.charAt(0).toUpperCase() + value.slice(1);
145
+ }
146
+
147
+ async function render(templateName, data) {
148
+ const template = await readFile(new URL(templateName, TEMPLATE_URL), 'utf8');
149
+ return ejs.render(template, data);
150
+ }
151
+
152
+ function renderFunction(descriptor) {
153
+ if (descriptor.type === 'api') return renderApiFunctionYaml(descriptor);
154
+ if (descriptor.type === 'inv') return renderInvFunctionYaml(descriptor);
155
+ if (descriptor.type === 'wbs') return renderWbsFunctionYaml(descriptor);
156
+ return renderSqsFunctionYaml(descriptor);
157
+ }
@@ -0,0 +1,84 @@
1
+ import { renderDynamicCrudFlowSchema } from './dynamicCrudFlowSchemaTemplate.js';
2
+
3
+ const ACTIONS = ['Create', 'Update', 'Delete', 'Get'];
4
+ const MESSAGE_ATTRIBUTES = ['userId', 'correlationId'];
5
+
6
+ export const dynamicCrudFlowSchemaPaths = ACTIONS.map(
7
+ action => `app/src/schemas/FlowSchemas/generateCode/${action}.js`
8
+ );
9
+
10
+ export function emitDynamicCrudFlowSchemas({ objects, flows = [] }) {
11
+ if (!Array.isArray(objects) || !Array.isArray(flows)) {
12
+ throw new TypeError('objects and flows must be arrays');
13
+ }
14
+ if (!objects.some(object => object?.generatedBy === 'userGenerated' || object?.generatedBy === 'systemGenerated')) {
15
+ return [];
16
+ }
17
+
18
+ return ACTIONS.map((action, index) => {
19
+ const flow = createDynamicFlow(action, hasBeforeLogicalStep(flows, action));
20
+ return {
21
+ path: dynamicCrudFlowSchemaPaths[index],
22
+ content: renderDynamicCrudFlowSchema(action, flow)
23
+ };
24
+ });
25
+ }
26
+
27
+ function createDynamicFlow(action, hasBeforeLogicalStep) {
28
+ const outputTopic = action !== 'Get';
29
+ const flowSteps = [
30
+ {
31
+ stepName: 'start',
32
+ properties: [],
33
+ messageAttributes: MESSAGE_ATTRIBUTES,
34
+ ...(outputTopic ? {
35
+ returnValues: {
36
+ properties: [],
37
+ messageAttributes: MESSAGE_ATTRIBUTES
38
+ }
39
+ } : {})
40
+ }
41
+ ];
42
+
43
+ if (hasBeforeLogicalStep) {
44
+ flowSteps.push({
45
+ stepName: 'BeforeLogical',
46
+ event: ['extTopic'],
47
+ properties: [],
48
+ messageAttributes: MESSAGE_ATTRIBUTES
49
+ });
50
+ }
51
+ if (action !== 'Get') {
52
+ flowSteps.push({
53
+ stepName: 'Complete',
54
+ event: ['extTopic'],
55
+ properties: [],
56
+ messageAttributes: MESSAGE_ATTRIBUTES
57
+ });
58
+ }
59
+
60
+ return {
61
+ flowTag: action,
62
+ isDynamicObjectType: true,
63
+ initiateBy: 'system',
64
+ handleObj: 'one',
65
+ statusType: 'none',
66
+ event: outputTopic ? ['ownTopic'] : ['lambdaSyncInv', 'lambdaSyncApi'],
67
+ outputTopic,
68
+ stepMessageAttributes: {
69
+ userId: { propertyName: 'x-correlation-base-user-id', type: 'string' },
70
+ correlationId: { propertyName: 'x-correlation-id', type: 'string' }
71
+ },
72
+ flowSteps
73
+ };
74
+ }
75
+
76
+ function hasBeforeLogicalStep(flows, action) {
77
+ return flows.some(flow => {
78
+ const config = flow?.generatedCodeConfig;
79
+ return config?.generatedCodeTag === action.toLowerCase()
80
+ && config.codeHookTag === 'beforeLogical'
81
+ && Array.isArray(flow.event)
82
+ && flow.event.includes(config.invocationType);
83
+ });
84
+ }
@@ -0,0 +1,16 @@
1
+ import { buildGenerationPlan } from '../../plan/buildGenerationPlan.js';
2
+ import { commitArtifacts } from '../../output/commitArtifacts.js';
3
+ import { compileProject } from '../../compile/compileProject.js';
4
+ import { loadLocalSchemaArrays } from './loadLocalSchemaArrays.js';
5
+ import { crudApplicationManagedPaths, emitCrudApplicationArtifacts } from './emitCrudApplicationArtifacts.js';
6
+
7
+ export async function generateCrudApplicationArtifacts(rootPath, options = {}) {
8
+ const project = compileProject({ ...options, rootPath });
9
+ const schemas = await loadLocalSchemaArrays(project);
10
+ const artifacts = await emitCrudApplicationArtifacts({ ...schemas, serviceTag: project.serviceTag });
11
+ const files = await commitArtifacts(buildGenerationPlan(project, artifacts, {
12
+ managedPaths: crudApplicationManagedPaths(),
13
+ managedScope: 'crud-application'
14
+ }));
15
+ return { project, files };
16
+ }
@@ -0,0 +1,21 @@
1
+ import { buildGenerationPlan } from '../../plan/buildGenerationPlan.js';
2
+ import { commitArtifacts } from '../../output/commitArtifacts.js';
3
+ import { compileProject } from '../../compile/compileProject.js';
4
+ import {
5
+ dynamicCrudFlowSchemaPaths,
6
+ emitDynamicCrudFlowSchemas
7
+ } from './emitDynamicCrudFlowSchemas.js';
8
+ import { loadLocalSchemaArrays } from './loadLocalSchemaArrays.js';
9
+
10
+ export async function generateDynamicCrudFlowSchemas(rootPath, options = {}) {
11
+ const project = compileProject({ ...options, rootPath });
12
+ const schemaInputs = await loadLocalSchemaArrays(project);
13
+ const plan = buildGenerationPlan(
14
+ project,
15
+ emitDynamicCrudFlowSchemas(schemaInputs),
16
+ { managedPaths: dynamicCrudFlowSchemaPaths, managedScope: 'crud-flow-schemas' }
17
+ );
18
+ const files = await commitArtifacts(plan);
19
+
20
+ return { project, files };
21
+ }
@@ -0,0 +1,8 @@
1
+ import { loadLocalSchemaDirectory } from '../../compile/loadSchemas.js';
2
+
3
+ export async function loadLocalSchemaArrays(project) {
4
+ return {
5
+ objects: await loadLocalSchemaDirectory(project, 'ObjectSchemas'),
6
+ flows: await loadLocalSchemaDirectory(project, 'FlowSchemas')
7
+ };
8
+ }
@@ -670,4 +670,4 @@ export default async function <%- flowTag %>(
670
670
  } catch (err) {
671
671
  throw err;
672
672
  }
673
- }
673
+ }
@@ -346,4 +346,4 @@ export default async function <%- flowTag %>(
346
346
  } catch (err) {
347
347
  throw err;
348
348
  }
349
- }
349
+ }
@@ -67,7 +67,7 @@ export default async function <%- flowTag %>BeforeLogicalMain(
67
67
  }
68
68
  }
69
69
  _izContext.logger.debug('identifiers:::: ', identifiers);
70
-
70
+
71
71
  // build parentFlowId
72
72
  <%_ if (flowTag === 'Create') { _%>
73
73
  const parentFlowId = identifierUuid();
@@ -155,4 +155,4 @@ export default async function <%- flowTag %>BeforeLogicalMain(
155
155
  } catch (err) {
156
156
  throw err;
157
157
  }
158
- }
158
+ }
@@ -0,0 +1,75 @@
1
+ import asyncFlowSharedLib from '@izara_project/izara-core-library-asynchronous-flow';
2
+ import callingFlowSharedLib from '@izara_project/izara-core-library-calling-flow';
3
+ import dynamodbSharedLib from '@izara_project/izara-core-library-dynamodb';
4
+ import snsSharedLib from '@izara_project/izara-core-library-sns';
5
+ import { sns } from '@izara_project/izara-core-library-external-request';
6
+ import { consts } from '@izara_project/izara-core-library-service-schemas';
7
+ import { NoRetryError } from '@izara_project/izara-core-library-core';
8
+
9
+ const { TOPIC_NAME_GENERATE_CODE } = consts;
10
+ const PREFIX = { ASYNC: '<%- action %>AsyncEndpoint' };
11
+
12
+ function empty(value) {
13
+ return value == null || (typeof value === 'object' && Object.keys(value).length === 0);
14
+ }
15
+
16
+ function validateInput(returnValue, status, graphServiceTag, errorsFound) {
17
+ if (!returnValue?.queryResult) errorsFound.push('message is not have property queryResult, should be not happen');
18
+ if (!returnValue?.requestParams?.objType) errorsFound.push('message is not have property objType, should be not happen');
19
+ if (!returnValue?.requestParams?.objInstanceFull) errorsFound.push('message is not have property objInstance, should be not objInstance');
20
+ if (status === 'error' && errorsFound.length === 0) errorsFound.push('[invalid]status is error not have errorsFound form graphService');
21
+ if (status === 'complete' && errorsFound.length > 0) errorsFound.push('[Invalid] status is complete should be not have errorsFound');
22
+ if (graphServiceTag == null) errorsFound.push('[Invalid] graphServerTag is not empty string');
23
+ }
24
+
25
+ export default async function <%- action %>Complete(_izContext, requestParams, passBackProperties) {
26
+ try {
27
+ const { returnValue, status, errorsFound = [], graphServiceTag, parentFlowId } = requestParams;
28
+ if (empty(returnValue?.requestParams)) throw new NoRetryError('message not an object');
29
+ validateInput(returnValue, status, graphServiceTag, errorsFound);
30
+ if (errorsFound.length > 0) errorsFound.push(errorsFound.join(','));
31
+
32
+ const awaitingStepId = await asyncFlowSharedLib.createAwaitingStepId(parentFlowId, PREFIX.ASYNC);
33
+ const pending = await asyncFlowSharedLib.findPendingStepAwaitingMultipleSteps(_izContext, awaitingStepId);
34
+ const result = await asyncFlowSharedLib.checkAllAwaitingStepsFinishedWithReturnParams(
35
+ _izContext, pending.pendingStepId, awaitingStepId, errorsFound
36
+ );
37
+
38
+ if (result.isComplete) {
39
+ const node = returnValue.queryResult.return<%- action %>Node ?? {};
40
+ const existsNode = node.existsNode && Object.keys(node.existsNode).length
41
+ ? { objType: returnValue.requestParams.objType, objInstanceFull: node.existsNode.objInstanceFull }
42
+ : null;
43
+ if (status === 'complete') {
44
+ await Promise.all((pending.listOfRecords ?? []).flatMap(records => Object.values(records).map(async record =>
45
+ dynamodbSharedLib.putItem(_izContext, await dynamodbSharedLib.tableName(_izContext, record.tableName, record.serviceTag), {
46
+ ...record.objInstanceFull.identifiers,
47
+ ...record.objInstanceFull.fields
48
+ })
49
+ )));
50
+ }
51
+ const message = callingFlowSharedLib.addParentPassBackPropertiesToSnsResponseMessageObject(passBackProperties, {
52
+ objType: returnValue.requestParams.objType,
53
+ objInstanceFull: node.objInstanceFull,
54
+ relationships: node.relationships,
55
+ parentFlowId: returnValue.parentFlowId,
56
+ existsNode,
57
+ status,
58
+ errorsFound
59
+ });
60
+ const messageAttributes = callingFlowSharedLib.addParentPassBackCallingFlowToSnsResponseMessageAttributes(passBackProperties, {});
61
+ await sns.publishAsync(_izContext, {
62
+ Message: JSON.stringify(message),
63
+ MessageAttributes: sns.createStringMessageAttributes(_izContext, messageAttributes),
64
+ TopicArn: await snsSharedLib.snsTopicArnByFlowSchema(_izContext, TOPIC_NAME_GENERATE_CODE.out<%- action %>NodeComplete)
65
+ });
66
+ //(<afterSendMessage>)
67
+ //(</afterSendMessage>)
68
+ }
69
+ await asyncFlowSharedLib.removeAwaitingMultipleStep(_izContext, awaitingStepId, pending.pendingStepId, errorsFound);
70
+ return { returnValue, status, errorsFound };
71
+ } catch (error) {
72
+ _izContext.logger.error('<%- action %>Complete error:', error);
73
+ throw error;
74
+ }
75
+ }
@@ -107,4 +107,4 @@ export const main = middleware.wrap(async (event, context) => {
107
107
  await postToConnection({ message: err.message }, connId);
108
108
  return (response.failure(err));
109
109
  }
110
- });
110
+ });