@izara_project/izara-core-generate-service-code 1.0.96 → 1.0.98

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 (219) hide show
  1. package/index.js +2 -2
  2. package/package.json +2 -1
  3. package/src/compile/loadSchemas.js +44 -322
  4. package/src/compile/loadSchemasRemote.js +195 -0
  5. package/src/compile/schemaValidatorSetup.js +143 -0
  6. package/src/emit/{crud → application/crud}/emitCrudApplicationArtifacts.js +2 -2
  7. package/src/emit/{crud → application/crud}/generateCrudApplicationArtifacts.js +2 -2
  8. package/src/emit/{crud → application/crud}/generateDynamicCrudFlowSchemas.js +2 -2
  9. package/src/emit/{crud → application/crud}/templates/FlowEndpoint_HdrWbs.ejs +2 -2
  10. package/src/emit/{crud → application/crud}/templates/FlowMain_Wbs.ejs +2 -2
  11. package/src/emit/{custom → application/custom}/customFlowS3.js +1 -1
  12. package/src/emit/{custom → application/custom}/customFlowSteps.js +1 -1
  13. package/src/emit/{custom → application/custom}/customFlowTemplates.js +1 -1
  14. package/src/emit/{custom → application/custom}/emitCustomFlowApplicationArtifacts.js +1 -1
  15. package/src/emit/{custom → application/custom}/generateCustomFlowApplicationArtifacts.js +2 -2
  16. package/src/emit/{custom → application/custom}/templates/s3/CreateObject_Main.ejs +5 -2
  17. package/src/emit/{custom → application/custom}/templates/triggerCache/CheckTriggerCache_Main.ejs +2 -2
  18. package/src/emit/{rbac → application/rbac}/emitRbacApplicationArtifacts.js +2 -2
  19. package/src/emit/{rbac → application/rbac}/generateCreateTargetRoleHandler.js +2 -2
  20. package/src/emit/{rbac → application/rbac}/generateDynamicRbacFlowSchemas.js +2 -2
  21. package/src/emit/{relationship → application/relationship}/emitRelationshipApplicationArtifacts.js +3 -3
  22. package/src/emit/{relationship → application/relationship}/generateDynamicRelationshipFlowSchemas.js +2 -2
  23. package/src/emit/{relationship → application/relationship}/generateRelationshipApplicationArtifacts.js +2 -2
  24. package/src/emit/{relationship → application/relationship}/templates/ChangeRelationship_Main.ejs +3 -2
  25. package/src/emit/{relationship → application/relationship}/templates/CreateRelationship_Main.ejs +3 -2
  26. package/src/emit/{relationship → application/relationship}/templates/DeleteRelationship_Main.ejs +3 -2
  27. package/src/emit/{relationship → application/relationship}/templates/GetRelationship_Main.ejs +3 -2
  28. package/src/emit/{relationship → application/relationship}/templates/MoveRelationship_Main.ejs +3 -2
  29. package/src/emit/{relationship → application/relationship}/templates/UpdateRelationship_Main.ejs +3 -2
  30. package/src/emit/{system → application/system}/emitSystemFindDataArtifacts.js +1 -1
  31. package/src/emit/{system → application/system}/templates/RegisterComplete_Main.ejs +6 -2
  32. package/src/emit/{system → application/system}/templates/Register_Main.ejs +6 -2
  33. package/src/emit/{system → application/system}/templates/WebSocketComplete_Main.ejs +3 -3
  34. package/src/emit/{resource → infrastructure/resources}/generateResourceArtifacts.js +2 -2
  35. package/src/emit/{resource → infrastructure/resources}/iamResourceArtifacts.js +3 -3
  36. package/src/emit/{resource → infrastructure/resources}/resourceState.js +4 -4
  37. package/src/emit/{attributeTree → schemas/attributeTree}/emitAttributeTreeSchemas.js +14 -22
  38. package/src/emit/schemas/attributeTree/emitAttributeTreeTargetValueStandard.js +132 -0
  39. package/src/emit/schemas/ledger/emitLedgerSchemas.js +392 -0
  40. package/src/emit/schemas/ledger/templates/LedgerObjectSchema.ejs +3 -0
  41. package/src/emit/schemas/ledger/templates/LedgerRelationshipSchema.ejs +1 -0
  42. package/src/emit/schemas/propertyValue/emitPropertyValueSchemas.js +329 -0
  43. package/src/emit/{systemText → schemas/systemText}/emitSystemTextSchemas.js +1 -1
  44. package/src/generate.js +34 -308
  45. package/src/{generateIntTest.js → intTest/generateIntTest.js} +2 -2
  46. package/src/{generateResourceIntTest.js → intTest/generateResourceIntTest.js} +2 -2
  47. package/src/output/mergeHooks.js +69 -15
  48. package/src/plan/domainRegistry.js +307 -0
  49. package/task.md +132 -0
  50. package/test/helpers/testProject.js +127 -0
  51. package/test/helpers/testProject.test.js +57 -0
  52. package/test/{core.test.js → integration/core.test.js} +3 -3
  53. package/test/{graphDrivenFlowSchema.test.js → integration/graphDrivenFlowSchema.test.js} +1 -1
  54. package/test/{intTestApi.test.js → integration/intTestApi.test.js} +1 -1
  55. package/test/{publicApi.test.js → integration/publicApi.test.js} +55 -2
  56. package/test/{createTargetRoleHandler.test.js → unit/application/createTargetRoleHandler.test.js} +1 -1
  57. package/test/{crudApplicationArtifacts.test.js → unit/application/crudApplicationArtifacts.test.js} +1 -1
  58. package/test/{customFlowApplicationArtifacts.test.js → unit/application/customFlowApplicationArtifacts.test.js} +18 -9
  59. package/test/{relationshipApplicationArtifacts.test.js → unit/application/relationshipApplicationArtifacts.test.js} +31 -1
  60. package/test/{systemFindDataArtifacts.test.js → unit/application/systemFindDataArtifacts.test.js} +1 -1
  61. package/test/{functionYamlArtifact.test.js → unit/infrastructure/functionYamlArtifact.test.js} +1 -1
  62. package/test/{resourceArtifacts.test.js → unit/infrastructure/resourceArtifacts.test.js} +2 -1
  63. package/test/unit/output/mergeHooks.test.js +268 -0
  64. package/test/unit/schemas/attributeTreeDirectives.test.js +177 -0
  65. package/test/{attributeTreeSchemas.test.js → unit/schemas/attributeTreeSchemas.test.js} +46 -102
  66. package/test/{dynamicCrudFlowSchemas.test.js → unit/schemas/dynamicCrudFlowSchemas.test.js} +2 -2
  67. package/test/{dynamicRbacFlowSchemas.test.js → unit/schemas/dynamicRbacFlowSchemas.test.js} +1 -1
  68. package/test/{dynamicRelationshipFlowSchemas.test.js → unit/schemas/dynamicRelationshipFlowSchemas.test.js} +11 -1
  69. package/test/{errorSchemas.test.js → unit/schemas/errorSchemas.test.js} +2 -2
  70. package/test/unit/schemas/ledgerSchemas.test.js +289 -0
  71. package/test/unit/schemas/propertyValueSchemas.test.js +265 -0
  72. package/test/{systemTextSchemas.test.js → unit/schemas/systemTextSchemas.test.js} +24 -36
  73. package/src/emit/attributeTree/emitAttributeTreeTargetSchemas.js +0 -153
  74. package/src/emit/attributeTree/resolveTargetServicePath.js +0 -111
  75. package/src/emit/crud/loadLocalSchemaArrays.js +0 -4
  76. /package/src/emit/{coreFunction → application/coreFunction}/emitCoreFunctionArtifacts.js +0 -0
  77. /package/src/emit/{coreFunction → application/coreFunction}/templates/CoreFunction_Yaml.ejs +0 -0
  78. /package/src/emit/{coreFunction → application/coreFunction}/templates/CoreResource_Yaml.ejs +0 -0
  79. /package/src/emit/{coreFunction → application/coreFunction}/templates/GenerateSeedDataDynamo_HdrInv.ejs +0 -0
  80. /package/src/emit/{coreFunction → application/coreFunction}/templates/GenerateSeedDataDynamo_Main.ejs +0 -0
  81. /package/src/emit/{coreFunction → application/coreFunction}/templates/GenerateSeedDataGraphData_HdrInv.ejs +0 -0
  82. /package/src/emit/{coreFunction → application/coreFunction}/templates/GenerateSeedDataGraphData_Main.ejs +0 -0
  83. /package/src/emit/{coreFunction → application/coreFunction}/templates/GenerateSeedDataGraphSchema_HdrInv.ejs +0 -0
  84. /package/src/emit/{coreFunction → application/coreFunction}/templates/GenerateSeedDataGraphSchema_Main.ejs +0 -0
  85. /package/src/emit/{coreFunction → application/coreFunction}/templates/GeneratedGraphNodeSchemas.ejs +0 -0
  86. /package/src/emit/{coreFunction → application/coreFunction}/templates/GeneratedGraphRelSchemas.ejs +0 -0
  87. /package/src/emit/{coreFunction → application/coreFunction}/templates/GeneratedTableConfigs.ejs +0 -0
  88. /package/src/emit/{coreFunction → application/coreFunction}/templates/InitialSetupConfig.ejs +0 -0
  89. /package/src/emit/{coreFunction → application/coreFunction}/templates/InitialSetupRunner.ejs +0 -0
  90. /package/src/emit/{coreFunction → application/coreFunction}/templates/InitialSetupRunner_initialSetup.ejs +0 -0
  91. /package/src/emit/{coreFunction → application/coreFunction}/templates/InitialSetupRunner_seedDynamo.ejs +0 -0
  92. /package/src/emit/{coreFunction → application/coreFunction}/templates/InitialSetupRunner_seedGraph.ejs +0 -0
  93. /package/src/emit/{coreFunction → application/coreFunction}/templates/InitialSetupRunner_seedRemove.ejs +0 -0
  94. /package/src/emit/{coreFunction → application/coreFunction}/templates/InitialSetupRunner_uploadSchema.ejs +0 -0
  95. /package/src/emit/{coreFunction → application/coreFunction}/templates/InitialSetup_HdrInv.ejs +0 -0
  96. /package/src/emit/{coreFunction → application/coreFunction}/templates/InitialSetup_Main.ejs +0 -0
  97. /package/src/emit/{coreFunction → application/coreFunction}/templates/RemoveSeedDataDynamo_HdrInv.ejs +0 -0
  98. /package/src/emit/{coreFunction → application/coreFunction}/templates/RemoveSeedDataDynamo_Main.ejs +0 -0
  99. /package/src/emit/{coreFunction → application/coreFunction}/templates/UploadSchema_HdrInv.ejs +0 -0
  100. /package/src/emit/{coreFunction → application/coreFunction}/templates/UploadSchema_Main.ejs +0 -0
  101. /package/src/emit/{crud → application/crud}/crudActionPlan.js +0 -0
  102. /package/src/emit/{crud → application/crud}/dynamicCrudFlowSchemaTemplate.js +0 -0
  103. /package/src/emit/{crud → application/crud}/emitDynamicCrudFlowSchemas.js +0 -0
  104. /package/src/emit/{crud → application/crud}/templates/CreateAfterHookCallback_Main.ejs +0 -0
  105. /package/src/emit/{crud → application/crud}/templates/CreateBeforeHookCallback_Main.ejs +0 -0
  106. /package/src/emit/{crud → application/crud}/templates/CreateComplete_Main.ejs +0 -0
  107. /package/src/emit/{crud → application/crud}/templates/CreateConfirmComplete_Main.ejs +0 -0
  108. /package/src/emit/{crud → application/crud}/templates/CreateEndpoint_Main.ejs +0 -0
  109. /package/src/emit/{crud → application/crud}/templates/CreateLogicalLib.ejs +0 -0
  110. /package/src/emit/{crud → application/crud}/templates/CreateNodeCallback_Main.ejs +0 -0
  111. /package/src/emit/{crud → application/crud}/templates/DeleteAfterHookCallback_Main.ejs +0 -0
  112. /package/src/emit/{crud → application/crud}/templates/DeleteBeforeHookCallback_Main.ejs +0 -0
  113. /package/src/emit/{crud → application/crud}/templates/DeleteComplete_Main.ejs +0 -0
  114. /package/src/emit/{crud → application/crud}/templates/DeleteEndpoint_Main.ejs +0 -0
  115. /package/src/emit/{crud → application/crud}/templates/DeleteLogicalLib.ejs +0 -0
  116. /package/src/emit/{crud → application/crud}/templates/FlowEndpointRbacCallback_Main.ejs +0 -0
  117. /package/src/emit/{crud → application/crud}/templates/GetEndpoint_Main.ejs +0 -0
  118. /package/src/emit/{crud → application/crud}/templates/GetRangeEndpoint_Main.ejs +0 -0
  119. /package/src/emit/{crud → application/crud}/templates/UpdateAfterHookCallback_Main.ejs +0 -0
  120. /package/src/emit/{crud → application/crud}/templates/UpdateBeforeHookCallback_Main.ejs +0 -0
  121. /package/src/emit/{crud → application/crud}/templates/UpdateComplete_Main.ejs +0 -0
  122. /package/src/emit/{crud → application/crud}/templates/UpdateEndpoint_Main.ejs +0 -0
  123. /package/src/emit/{crud → application/crud}/templates/UpdateLogicalLib.ejs +0 -0
  124. /package/src/emit/{custom → application/custom}/customFlowPaths.js +0 -0
  125. /package/src/emit/{custom → application/custom}/customFlows.js +0 -0
  126. /package/src/emit/{custom → application/custom}/templates/FlowEndpointRbacCallback_Main.ejs +0 -0
  127. /package/src/emit/{custom → application/custom}/templates/FlowEndpoint_Main.ejs +0 -0
  128. /package/src/emit/{custom → application/custom}/templates/FlowStep_Main.ejs +0 -0
  129. /package/src/emit/{custom → application/custom}/templates/s3/ConfirmReserved_HdrSqs.ejs +0 -0
  130. /package/src/emit/{custom → application/custom}/templates/s3/ConfirmReserved_Main.ejs +0 -0
  131. /package/src/emit/{custom → application/custom}/templates/s3/CreateObject_HdrWbs.ejs +0 -0
  132. /package/src/emit/{custom → application/custom}/templates/s3/CreatePreSignUrl_HdrSqs.ejs +0 -0
  133. /package/src/emit/{custom → application/custom}/templates/s3/CreatePreSignUrl_Main.ejs +0 -0
  134. /package/src/emit/{custom → application/custom}/templates/s3/FlowHandler_HdrS3.ejs +0 -0
  135. /package/src/emit/{custom → application/custom}/templates/s3/ProcessS3File_Main.ejs +0 -0
  136. /package/src/emit/{custom → application/custom}/templates/s3/ReservedLimit_HdrSqs.ejs +0 -0
  137. /package/src/emit/{custom → application/custom}/templates/s3/ReservedLimit_Main.ejs +0 -0
  138. /package/src/emit/{custom → application/custom}/templates/triggerCache/CheckTriggerCache_HdrSqs.ejs +0 -0
  139. /package/src/emit/{custom → application/custom}/templates/triggerCache/TriggerCacheComplete_Main.ejs +0 -0
  140. /package/src/emit/{custom → application/custom}/templates/triggerCache/TriggerCache_Main.ejs +0 -0
  141. /package/src/emit/{rbac → application/rbac}/emitDynamicRbacFlowSchemas.js +0 -0
  142. /package/src/emit/{rbac → application/rbac}/rbacFlowTag.js +0 -0
  143. /package/src/emit/{rbac → application/rbac}/templates/CancelUsage_Main.ejs +0 -0
  144. /package/src/emit/{rbac → application/rbac}/templates/ConfirmUsage_Main.ejs +0 -0
  145. /package/src/emit/{rbac → application/rbac}/templates/CreateTargetRole_HdrSqs.ejs +0 -0
  146. /package/src/emit/{rbac → application/rbac}/templates/CreateTargetRole_Main.ejs +0 -0
  147. /package/src/emit/{rbac → application/rbac}/templates/DeleteTargetRole_Main.ejs +0 -0
  148. /package/src/emit/{rbac → application/rbac}/templates/DynamicRbacFlowSchema.ejs +0 -0
  149. /package/src/emit/{rbac → application/rbac}/templates/GetMyPermissions_Main.ejs +0 -0
  150. /package/src/emit/{rbac → application/rbac}/templates/GetTargetRole_Main.ejs +0 -0
  151. /package/src/emit/{rbac → application/rbac}/templates/ListRbac_HdrApi.ejs +0 -0
  152. /package/src/emit/{rbac → application/rbac}/templates/ListRbac_HdrSqs.ejs +0 -0
  153. /package/src/emit/{rbac → application/rbac}/templates/ListRbac_Main.ejs +0 -0
  154. /package/src/emit/{rbac → application/rbac}/templates/RbacMutation_Main.ejs +0 -0
  155. /package/src/emit/{rbac → application/rbac}/templates/ReservedDynamicUsage_Main.ejs +0 -0
  156. /package/src/emit/{rbac → application/rbac}/templates/UpdateTargetRole_Main.ejs +0 -0
  157. /package/src/emit/{rbac → application/rbac}/templates/UserRbacFlow_HdrSqs.ejs +0 -0
  158. /package/src/emit/{rbac → application/rbac}/templates/UserRbacFlow_Main.ejs +0 -0
  159. /package/src/emit/{rbac → application/rbac}/templates/UserRoleMutation_Main.ejs +0 -0
  160. /package/src/emit/{relationship → application/relationship}/emitDynamicRelationshipFlowSchemas.js +0 -0
  161. /package/src/emit/{relationship → application/relationship}/templates/ChangeRelationshipComplete_HdrSqs.ejs +0 -0
  162. /package/src/emit/{relationship → application/relationship}/templates/ChangeRelationshipComplete_Main.ejs +0 -0
  163. /package/src/emit/{relationship → application/relationship}/templates/CreateRelationshipComplete_HdrSqs.ejs +0 -0
  164. /package/src/emit/{relationship → application/relationship}/templates/CreateRelationshipComplete_Main.ejs +0 -0
  165. /package/src/emit/{relationship → application/relationship}/templates/DeleteRelationshipComplete_HdrSqs.ejs +0 -0
  166. /package/src/emit/{relationship → application/relationship}/templates/DeleteRelationshipComplete_Main.ejs +0 -0
  167. /package/src/emit/{relationship → application/relationship}/templates/GetRelationshipComplete_HdrSqs.ejs +0 -0
  168. /package/src/emit/{relationship → application/relationship}/templates/GetRelationshipComplete_Main.ejs +0 -0
  169. /package/src/emit/{relationship → application/relationship}/templates/MoveRelationshipComplete_HdrSqs.ejs +0 -0
  170. /package/src/emit/{relationship → application/relationship}/templates/MoveRelationshipComplete_Main.ejs +0 -0
  171. /package/src/emit/{relationship → application/relationship}/templates/UpdateRelationshipComplete_HdrSqs.ejs +0 -0
  172. /package/src/emit/{relationship → application/relationship}/templates/UpdateRelationshipComplete_Main.ejs +0 -0
  173. /package/src/emit/{system → application/system}/emitSystemWebSocketArtifacts.js +0 -0
  174. /package/src/emit/{system → application/system}/templates/RegisterComplete_HdrSqs.ejs +0 -0
  175. /package/src/emit/{system → application/system}/templates/RegisterComplete_Yaml.ejs +0 -0
  176. /package/src/emit/{system → application/system}/templates/RegisterWbs_Yaml.ejs +0 -0
  177. /package/src/emit/{system → application/system}/templates/Register_HdrWbs.ejs +0 -0
  178. /package/src/emit/{system → application/system}/templates/WebSocketComplete_HdrSqs.ejs +0 -0
  179. /package/src/emit/{system → application/system}/templates/WebSocketComplete_Yaml.ejs +0 -0
  180. /package/src/emit/{system → application/system}/templates/WebSocketConnect.ejs +0 -0
  181. /package/src/emit/{system → application/system}/templates/WebSocketConnect_Yaml.ejs +0 -0
  182. /package/src/emit/{function → infrastructure/functions}/functionYamlArtifact.js +0 -0
  183. /package/src/emit/{function → infrastructure/functions}/templates/ApiFunction_Yaml.ejs +0 -0
  184. /package/src/emit/{function → infrastructure/functions}/templates/EventBridgeFunction_Yaml.ejs +0 -0
  185. /package/src/emit/{function → infrastructure/functions}/templates/InvFunction_Yaml.ejs +0 -0
  186. /package/src/emit/{function → infrastructure/functions}/templates/S3Function_Yaml.ejs +0 -0
  187. /package/src/emit/{function → infrastructure/functions}/templates/SqsFunction_Yaml.ejs +0 -0
  188. /package/src/emit/{function → infrastructure/functions}/templates/WbsFunction_Yaml.ejs +0 -0
  189. /package/src/emit/{resource → infrastructure/resources}/dynamoResourceArtifacts.js +0 -0
  190. /package/src/emit/{resource → infrastructure/resources}/emitResourceArtifacts.js +0 -0
  191. /package/src/emit/{resource → infrastructure/resources}/resourceTemplate.js +0 -0
  192. /package/src/emit/{resource → infrastructure/resources}/s3ResourceArtifacts.js +0 -0
  193. /package/src/emit/{resource → infrastructure/resources}/sqsResourceArtifacts.js +0 -0
  194. /package/src/emit/{resource → infrastructure/resources}/templates/DynamoDBTable_Yaml.ejs +0 -0
  195. /package/src/emit/{resource → infrastructure/resources}/templates/FlowOut_Yaml.ejs +0 -0
  196. /package/src/emit/{resource → infrastructure/resources}/templates/GeneratedLambdaRoleServiceConfig.ejs +0 -0
  197. /package/src/emit/{resource → infrastructure/resources}/templates/ResourceSqsYaml.ejs +0 -0
  198. /package/src/emit/{resource → infrastructure/resources}/templates/ResourceYaml.ejs +0 -0
  199. /package/src/emit/{resource → infrastructure/resources}/templates/S3Bucket_Yaml.ejs +0 -0
  200. /package/src/emit/{resource → infrastructure/resources}/templates/S3Subscription_Yaml.ejs +0 -0
  201. /package/src/emit/{resource → infrastructure/resources}/templates/SharedResource_Yaml.ejs +0 -0
  202. /package/src/emit/{resource → infrastructure/resources}/templates/SystemDynamoDB_Yaml.ejs +0 -0
  203. /package/src/emit/{resource → infrastructure/resources}/templates/WebSocketSubscription_Yaml.ejs +0 -0
  204. /package/src/emit/{error → schemas/error}/emitErrorSchemas.js +0 -0
  205. /package/src/emit/{error → schemas/error}/templates/errorSchema.ejs +0 -0
  206. /package/src/emit/{systemText → schemas/systemText}/templates/SystemTextSchemas.ejs +0 -0
  207. /package/src/{generateResources/IntTest → intTest/generators}/consts.js +0 -0
  208. /package/src/{generateResources/IntTest → intTest/generators}/generateResources/generateResources.js +0 -0
  209. /package/src/{generateResources/IntTest → intTest/generators}/generateResources/templateResources.ejs +0 -0
  210. /package/src/{generateResources/IntTest → intTest/generators}/generateTests/events/events.js +0 -0
  211. /package/src/{generateResources/IntTest → intTest/generators}/generateTests/events/templateEvents.ejs +0 -0
  212. /package/src/{generateResources/IntTest → intTest/generators}/generateTests/generateTemplate.js +0 -0
  213. /package/src/{generateResources/IntTest → intTest/generators}/generateTests/pathIntTest/pathIntTest.js +0 -0
  214. /package/src/{generateResources/IntTest → intTest/generators}/generateTests/pathIntTest/template.ejs +0 -0
  215. /package/src/{generateResources/IntTest → intTest/generators}/generateTests/tests/templateTests.ejs +0 -0
  216. /package/src/{generateResources/IntTest → intTest/generators}/generateTests/tests/tests.js +0 -0
  217. /package/src/{generateResources/IntTest → intTest/generators}/libs/IntTestGenerateLib.js +0 -0
  218. /package/src/{generateResources/IntTest → intTest/generators}/upload/uploadIntTest.js +0 -0
  219. /package/src/{intTestGeneratorShared.js → intTest/intTestGeneratorShared.js} +0 -0
package/src/generate.js CHANGED
@@ -1,74 +1,13 @@
1
- import fs from 'node:fs';
2
- import path from 'node:path';
3
1
  import { buildGenerationPlan } from './plan/buildGenerationPlan.js';
2
+ import { resolveEmissionGroups } from './plan/domainRegistry.js';
4
3
  import { commitArtifacts } from './output/commitArtifacts.js';
5
4
  import { compileProject } from './compile/compileProject.js';
6
- import {
7
- crudApplicationManagedPaths,
8
- emitCrudApplicationArtifacts
9
- } from './emit/crud/emitCrudApplicationArtifacts.js';
10
- import {
11
- dynamicCrudFlowSchemaPaths,
12
- emitDynamicCrudFlowSchemas
13
- } from './emit/crud/emitDynamicCrudFlowSchemas.js';
14
- import {
15
- customFlowApplicationManagedPaths,
16
- emitCustomFlowApplicationArtifacts
17
- } from './emit/custom/emitCustomFlowApplicationArtifacts.js';
18
- import {
19
- emitDynamicRbacFlowSchemas,
20
- rbacFlowSchemaManagedPaths
21
- } from './emit/rbac/emitDynamicRbacFlowSchemas.js';
22
- import {
23
- emitRbacApplicationArtifacts,
24
- rbacApplicationManagedPaths
25
- } from './emit/rbac/emitRbacApplicationArtifacts.js';
26
- import {
27
- dynamicRelationshipFlowSchemaManagedPaths,
28
- emitDynamicRelationshipFlowSchemas
29
- } from './emit/relationship/emitDynamicRelationshipFlowSchemas.js';
30
- import {
31
- emitRelationshipApplicationArtifacts,
32
- relationshipApplicationManagedPaths
33
- } from './emit/relationship/emitRelationshipApplicationArtifacts.js';
34
- import {
35
- emitResourceArtifacts,
36
- resourceArtifactPaths
37
- } from './emit/resource/emitResourceArtifacts.js';
38
5
  import {
39
6
  loadLocalSchemaDirectory,
7
+ loadGenerateDirectives,
40
8
  resolveExtendedObjectSchemas,
41
9
  resolveGraphServiceTags
42
10
  } from './compile/loadSchemas.js';
43
- import {
44
- emitSystemWebSocketArtifacts,
45
- hasSystemWebSocket,
46
- systemWebSocketManagedPaths
47
- } from './emit/system/emitSystemWebSocketArtifacts.js';
48
- import {
49
- emitSystemFindDataArtifacts,
50
- findDataManagedPaths
51
- } from './emit/system/emitSystemFindDataArtifacts.js';
52
- import {
53
- emitCoreFunctionArtifacts,
54
- coreFunctionManagedPaths
55
- } from './emit/coreFunction/emitCoreFunctionArtifacts.js';
56
- import {
57
- emitSystemTextSchemas,
58
- systemTextSchemaManagedPaths
59
- } from './emit/systemText/emitSystemTextSchemas.js';
60
- import {
61
- emitAttributeTreeObjectSchemas,
62
- emitAttributeTreeRelationshipSchemas,
63
- attributeTreeObjectSchemaManagedPaths,
64
- attributeTreeRelationshipSchemaManagedPaths,
65
- resolveTargetServicePath,
66
- emitAttributeTreeTargetSchemas
67
- } from './emit/attributeTree/emitAttributeTreeSchemas.js';
68
- import {
69
- emitErrorSchemas,
70
- errorSchemaManagedPaths
71
- } from './emit/error/emitErrorSchemas.js';
72
11
 
73
12
  export async function generate(rootPath, options = {}) {
74
13
  const startedAt = Date.now();
@@ -83,13 +22,23 @@ export async function generate(rootPath, options = {}) {
83
22
  relationships,
84
23
  flows,
85
24
  notifications,
86
- errors
25
+ errors,
26
+ directives
87
27
  ] = await Promise.all([
88
28
  loadLocalSchemaDirectory(project, 'ObjectSchemas', schemaLoadOptions),
89
- loadLocalSchemaDirectory(project, 'RelationshipSchemas', schemaLoadOptions),
29
+ loadLocalSchemaDirectory(
30
+ project,
31
+ 'RelationshipSchemas',
32
+ schemaLoadOptions
33
+ ),
90
34
  loadLocalSchemaDirectory(project, 'FlowSchemas', schemaLoadOptions),
91
- loadLocalSchemaDirectory(project, 'NotificationSchemas', schemaLoadOptions),
92
- loadLocalSchemaDirectory(project, 'ErrorSchemas', schemaLoadOptions)
35
+ loadLocalSchemaDirectory(
36
+ project,
37
+ 'NotificationSchemas',
38
+ schemaLoadOptions
39
+ ),
40
+ loadLocalSchemaDirectory(project, 'ErrorSchemas', schemaLoadOptions),
41
+ loadGenerateDirectives(project, schemaLoadOptions)
93
42
  ]);
94
43
  const schemaBucketName =
95
44
  options.schemaBucketName || process.env.iz_serviceSchemaBucketName;
@@ -105,27 +54,35 @@ export async function generate(rootPath, options = {}) {
105
54
  relationships,
106
55
  schemaBucketName
107
56
  );
57
+ const objectNames = objects.map((obj) => obj.objectType).filter(Boolean);
58
+ let objectSummary = '';
59
+ if (objectNames.length > 0) {
60
+ objectSummary = ` (${objectNames.join(', ')})`;
61
+ }
108
62
  console.log(
109
- `[DEBUG] [Generate] STATUS=SCHEMAS_LOADED | ` +
110
- `objects=${objects.length} ` +
63
+ `[INFO] [Generate] STATUS=SCHEMAS_LOADED | ` +
64
+ `objects=${objects.length}${objectSummary} ` +
111
65
  `relationships=${relationships.length} flows=${flows.length} ` +
112
66
  `notifications=${notifications.length} ` +
113
67
  `errors=${errors.length}`
114
68
  );
115
- for (const objectSchema of objects) {
116
- const objectType = objectSchema.objectType || 'unknown';
117
- console.log(
118
- `[DEBUG] [Generate] OBJECT_SCHEMA | objectType=${objectType}\n` +
119
- JSON.stringify(objectSchema, null, 2)
120
- );
69
+ if (options.verbose || process.env.GENERATE_VERBOSE) {
70
+ for (const objectSchema of objects) {
71
+ const objectType = objectSchema.objectType || 'unknown';
72
+ console.log(
73
+ `[DEBUG] [Generate] OBJECT_SCHEMA | objectType=${objectType}\n` +
74
+ JSON.stringify(objectSchema, null, 2)
75
+ );
76
+ }
121
77
  }
122
- const groups = await _emitGroups({
78
+ const groups = await resolveEmissionGroups({
123
79
  project,
124
80
  objects,
125
81
  relationships,
126
82
  flows,
127
83
  notifications,
128
84
  errors,
85
+ directives,
129
86
  objectGraphServiceTags,
130
87
  relationshipGraphServiceTags,
131
88
  logger: options.logger
@@ -135,7 +92,7 @@ export async function generate(rootPath, options = {}) {
135
92
  });
136
93
  const emittedScopeSummary = scopeCounts.join(' ');
137
94
  console.log(
138
- `[DEBUG] [Generate] STATUS=ARTIFACTS_EMITTED | ${emittedScopeSummary}`
95
+ `[INFO] [Generate] STATUS=ARTIFACTS_EMITTED | ${emittedScopeSummary}`
139
96
  );
140
97
  let files = [];
141
98
  if (groups.length > 0) {
@@ -151,11 +108,6 @@ export async function generate(rootPath, options = {}) {
151
108
  )
152
109
  );
153
110
  }
154
- await _emitTargetServiceAttributeTreeSchemas({
155
- project,
156
- objects,
157
- logger: options.logger
158
- });
159
111
  const durationMs = Date.now() - startedAt;
160
112
  console.log(
161
113
  `[INFO] [Generate] STATUS=FINISHED | ` +
@@ -173,229 +125,3 @@ export async function generate(rootPath, options = {}) {
173
125
  }
174
126
  }
175
127
 
176
- async function _emitGroups({
177
- project,
178
- objects,
179
- relationships,
180
- flows,
181
- notifications,
182
- errors,
183
- objectGraphServiceTags,
184
- relationshipGraphServiceTags,
185
- logger
186
- }) {
187
- const [
188
- crud,
189
- relationship,
190
- rbac,
191
- system,
192
- findData,
193
- resource,
194
- coreFunction,
195
- systemText,
196
- errorSchemas
197
- ] = await Promise.all([
198
- emitCrudApplicationArtifacts({
199
- objects,
200
- flows,
201
- serviceTag: project.serviceTag,
202
- logger
203
- }),
204
- emitRelationshipApplicationArtifacts({
205
- relationships,
206
- flows,
207
- serviceTag: project.serviceTag
208
- }),
209
- emitRbacApplicationArtifacts(objects),
210
- emitSystemWebSocketArtifacts(flows, {
211
- includeRelationshipOwnTopic: true,
212
- objects,
213
- relationships
214
- }),
215
- emitSystemFindDataArtifacts(objects),
216
- emitResourceArtifacts({ objects, relationships, flows }),
217
- emitCoreFunctionArtifacts({
218
- project,
219
- objects,
220
- relationships,
221
- flows,
222
- objectGraphServiceTags,
223
- relationshipGraphServiceTags
224
- }),
225
- emitSystemTextSchemas({
226
- project,
227
- objects,
228
- relationships,
229
- flows,
230
- notifications
231
- }),
232
- emitErrorSchemas({
233
- project,
234
- errors,
235
- objectGraphServiceTags
236
- })
237
- ]);
238
- const custom = await emitCustomFlowApplicationArtifacts(flows, {
239
- objects
240
- });
241
-
242
- const systemFunctions = [
243
- ...(system.functions ?? []),
244
- ...(findData.functions ?? [])
245
- ].filter(Boolean);
246
-
247
- const findDataArtifacts = [...(findData.artifacts ?? [])];
248
-
249
- if (systemFunctions.length > 0) {
250
- findDataArtifacts.push({
251
- path: 'app/sls_yaml/generatedCode/source/flow-system.yml',
252
- content: systemFunctions.join('\n\n')
253
- });
254
- }
255
-
256
- let resolvedCoreFunctionManagedPaths = coreFunctionManagedPaths;
257
- if (typeof coreFunctionManagedPaths === 'function') {
258
- resolvedCoreFunctionManagedPaths = coreFunctionManagedPaths({
259
- project,
260
- objects,
261
- relationships,
262
- flows,
263
- objectGraphServiceTags,
264
- relationshipGraphServiceTags
265
- });
266
- }
267
-
268
- return [
269
- {
270
- scope: 'crud-flow-schemas',
271
- managedPaths: dynamicCrudFlowSchemaPaths,
272
- artifacts: emitDynamicCrudFlowSchemas({ objects, flows, logger })
273
- },
274
- {
275
- scope: 'relationship-flow-schemas',
276
- managedPaths: dynamicRelationshipFlowSchemaManagedPaths(relationships),
277
- artifacts: emitDynamicRelationshipFlowSchemas({ relationships })
278
- },
279
- {
280
- scope: 'rbac-flow-schemas',
281
- managedPaths: rbacFlowSchemaManagedPaths(objects),
282
- artifacts: await emitDynamicRbacFlowSchemas({
283
- objects,
284
- serviceTag: project.serviceTag
285
- })
286
- },
287
- {
288
- scope: 'attribute-tree-object-schemas',
289
- managedPaths: attributeTreeObjectSchemaManagedPaths(objects),
290
- artifacts: emitAttributeTreeObjectSchemas({
291
- objects,
292
- serviceTag: project.serviceTag
293
- })
294
- },
295
- {
296
- scope: 'attribute-tree-relationship-schemas',
297
- managedPaths: attributeTreeRelationshipSchemaManagedPaths(objects),
298
- artifacts: emitAttributeTreeRelationshipSchemas({
299
- objects,
300
- serviceTag: project.serviceTag
301
- })
302
- },
303
- {
304
- scope: 'crud-application',
305
- managedPaths: crudApplicationManagedPaths(),
306
- artifacts: crud
307
- },
308
- {
309
- scope: 'relationship-application',
310
- managedPaths: relationshipApplicationManagedPaths(),
311
- artifacts: relationship
312
- },
313
- {
314
- scope: 'rbac-application',
315
- managedPaths: rbacApplicationManagedPaths(objects),
316
- artifacts: rbac
317
- },
318
- {
319
- scope: 'system-websocket',
320
- managedPaths: systemWebSocketManagedPaths(),
321
- artifacts: system.artifacts
322
- },
323
- {
324
- scope: 'system-find-data',
325
- managedPaths: findDataManagedPaths(),
326
- artifacts: findDataArtifacts
327
- },
328
- {
329
- scope: 'custom-flow-application',
330
- managedPaths: customFlowApplicationManagedPaths(flows, { objects }),
331
- artifacts: custom
332
- },
333
- {
334
- scope: 'shared-resources',
335
- managedPaths: resourceArtifactPaths,
336
- artifacts: resource
337
- },
338
- {
339
- scope: 'core-function',
340
- managedPaths: resolvedCoreFunctionManagedPaths,
341
- artifacts: coreFunction
342
- },
343
- {
344
- scope: 'system-text-schemas',
345
- managedPaths: systemTextSchemaManagedPaths(),
346
- artifacts: systemText
347
- },
348
- {
349
- scope: 'error-schemas',
350
- managedPaths: errorSchemaManagedPaths(errors),
351
- artifacts: errorSchemas
352
- }
353
- ];
354
- }
355
-
356
- async function _emitTargetServiceAttributeTreeSchemas({
357
- project,
358
- objects,
359
- logger
360
- }) {
361
- if (!Array.isArray(objects)) {
362
- return;
363
- }
364
- for (const object of objects) {
365
- if (!Array.isArray(object?.addOnDataStructure)) {
366
- continue;
367
- }
368
- for (const addOn of object.addOnDataStructure) {
369
- if (addOn?.type === 'attributeTree' && addOn?.attributeTreeTag) {
370
- const attributeTag = addOn.attributeTreeTag;
371
- const targetServiceRoot = resolveTargetServicePath({
372
- currentServiceRoot: project.rootPath,
373
- attributeTag
374
- });
375
- if (targetServiceRoot) {
376
- const artifacts = emitAttributeTreeTargetSchemas({
377
- attributeTag,
378
- targetServiceRoot
379
- });
380
- for (const artifact of artifacts) {
381
- await fs.promises.mkdir(path.dirname(artifact.path), {
382
- recursive: true
383
- });
384
- await fs.promises.writeFile(
385
- artifact.path,
386
- artifact.content,
387
- 'utf8'
388
- );
389
- }
390
- if (logger && typeof logger.info === 'function') {
391
- logger.info(
392
- `[INFO] [AttributeTree] Target schemas emitted for ` +
393
- `tag=${attributeTag} to ${targetServiceRoot}`
394
- );
395
- }
396
- }
397
- }
398
- }
399
- }
400
- }
401
-
@@ -25,11 +25,11 @@ import { join } from 'path';
25
25
  import ejsLib from 'ejs';
26
26
  import beautify from 'js-beautify/js/index.js';
27
27
 
28
- import generateTestTemplate from './generateResources/IntTest/generateTests/generateTemplate.js';
28
+ import generateTestTemplate from './generators/generateTests/generateTemplate.js';
29
29
  import {
30
30
  DEFAULT_BUCKET,
31
31
  uploadToS3
32
- } from './generateResources/IntTest/upload/uploadIntTest.js';
32
+ } from './generators/upload/uploadIntTest.js';
33
33
  import {
34
34
  getIntTestOutputPath,
35
35
  getServiceTag,
@@ -18,11 +18,11 @@ import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'fs';
18
18
  import { join } from 'path';
19
19
  import ejsLib from 'ejs';
20
20
 
21
- import generateResourceTemplate from './generateResources/IntTest/generateResources/generateResources.js';
21
+ import generateResourceTemplate from './generators/generateResources/generateResources.js';
22
22
  import {
23
23
  DEFAULT_BUCKET,
24
24
  uploadToS3
25
- } from './generateResources/IntTest/upload/uploadIntTest.js';
25
+ } from './generators/upload/uploadIntTest.js';
26
26
  import {
27
27
  getIntTestOutputPath,
28
28
  getServiceTag,
@@ -24,7 +24,10 @@ async function mergeHook(outputRoot, artifact) {
24
24
  }
25
25
  }
26
26
 
27
- if (sourceContent !== null && (artifact.writeWhenFileExist === false || artifact.writeWhenFileExists === false)) {
27
+ const skipWrite =
28
+ artifact.writeWhenFileExist === false ||
29
+ artifact.writeWhenFileExists === false;
30
+ if (sourceContent !== null && skipWrite) {
28
31
  return sourceContent;
29
32
  }
30
33
 
@@ -37,32 +40,83 @@ async function mergeHook(outputRoot, artifact) {
37
40
  return artifact.content;
38
41
  }
39
42
 
43
+ const tagOccurrences = new Map();
40
44
  return artifact.content.replace(
41
45
  matchers.anyTag,
42
46
  (_match, p1, _body1, p2) => {
43
- const tagName = p1 || p2;
44
- const hookBlock = sourceContent.match(matchers.tagPattern(tagName))?.[0];
45
- return hookBlock ?? _match;
47
+ const tagName = _extractTagName(p1, p2);
48
+ if (!tagName) {
49
+ return _match;
50
+ }
51
+ let count = 0;
52
+ if (tagOccurrences.has(tagName)) {
53
+ count = tagOccurrences.get(tagName);
54
+ }
55
+ tagOccurrences.set(tagName, count + 1);
56
+
57
+ const matches = sourceContent.match(matchers.tagPattern(tagName));
58
+ if (!matches || count >= matches.length) {
59
+ return _match;
60
+ }
61
+ const hookBlock = matches[count];
62
+ if (hookBlock !== null && hookBlock !== undefined) {
63
+ return hookBlock;
64
+ }
65
+ return _match;
46
66
  }
47
67
  );
48
68
  }
49
69
 
70
+ function _extractTagName(p1, p2) {
71
+ if (typeof p1 === 'string' && p1.length > 0) {
72
+ return p1;
73
+ }
74
+ if (typeof p2 === 'string' && p2.length > 0) {
75
+ return p2;
76
+ }
77
+ return '';
78
+ }
79
+
50
80
  function hookMatchers(filePath) {
51
- if (filePath.endsWith('.js')) {
81
+ const lower = filePath.toLowerCase();
82
+ if (
83
+ lower.endsWith('.js') ||
84
+ lower.endsWith('.mjs') ||
85
+ lower.endsWith('.cjs')
86
+ ) {
87
+ const jsP1 =
88
+ '\\/\\/\\s*\\(<\\s*([\\w.-]+)\\s*>\\)([\\s\\S]*?)' +
89
+ '\\/\\/\\s*\\(<\\/\\s*\\1\\s*>\\)';
90
+ const jsP2 =
91
+ '\\/\\/\\s*<#\\s*([\\w.-]+)\\s*#>([\\s\\S]*?)' +
92
+ '\\/\\/\\s*<#\\/\\s*\\3\\s*#>';
52
93
  return {
53
- anyTag: /(?:\/\/\(<(\w+)>\)([\s\S]*?)\/\/\(<\/\1>\)|\/\/\s*<#(\w+)#>([\s\S]*?)\/\/\s*<#\/\3#>)/gm,
54
- tagPattern: (name) =>
55
- new RegExp(
56
- `(?:\\/\\/\\(<${name}>\\)([\\s\\S]*?)\\/\\/\\(<\\/${name}>\\)|\\/\\/\\s*<#${name}#>([\\s\\S]*?)\\/\\/\\s*<#\\/${name}#>)`,
57
- 'gm'
58
- )
94
+ anyTag: new RegExp(`(?:${jsP1}|${jsP2})`, 'gm'),
95
+ tagPattern: (name) => {
96
+ const esc = name.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
97
+ const p1 =
98
+ `\\/\\/\\s*\\(<\\s*${esc}\\s*>\\)([\\s\\S]*?)` +
99
+ `\\/\\/\\s*\\(<\\/\\s*${esc}\\s*>\\)`;
100
+ const p2 =
101
+ `\\/\\/\\s*<#\\s*${esc}\\s*#>([\\s\\S]*?)` +
102
+ `\\/\\/\\s*<#\\/\\s*${esc}\\s*#>`;
103
+ return new RegExp(`(?:${p1}|${p2})`, 'gm');
104
+ }
59
105
  };
60
106
  }
61
- if (filePath.endsWith('.yml') || filePath.endsWith('.yaml')) {
107
+ if (lower.endsWith('.yml') || lower.endsWith('.yaml')) {
108
+ const ymlPattern =
109
+ '#\\s*<#\\s*([\\w.-]+)\\s*#>([\\s\\S]*?)' +
110
+ '#\\s*<#\\/\\s*\\1\\s*#>';
62
111
  return {
63
- anyTag: /#<#(\w+)#>([\s\S]*?)#<#\/\1#>/gm,
64
- tagPattern: (name) =>
65
- new RegExp(`#<#${name}#>([\\s\\S]*?)#<#\\/${name}#>`, 'gm')
112
+ anyTag: new RegExp(ymlPattern, 'gm'),
113
+ tagPattern: (name) => {
114
+ const esc = name.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
115
+ return new RegExp(
116
+ `#\\s*<#\\s*${esc}\\s*#>([\\s\\S]*?)#\\s*<#\\/\\s*${esc}\\s*#>`,
117
+ 'gm'
118
+ );
119
+ }
66
120
  };
67
121
  }
68
122
  return null;