@izara_project/izara-core-generate-service-code 1.0.91 → 1.0.93

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 (36) hide show
  1. package/package.json +7 -10
  2. package/src/compile/flowValidator.js +6 -0
  3. package/src/compile/loadSchemas.js +195 -69
  4. package/src/emit/coreFunction/templates/UploadSchema_Main.ejs +2 -2
  5. package/src/emit/crud/generateCrudApplicationArtifacts.js +15 -17
  6. package/src/emit/crud/generateDynamicCrudFlowSchemas.js +16 -21
  7. package/src/emit/crud/loadLocalSchemaArrays.js +4 -8
  8. package/src/emit/custom/customFlowPaths.js +149 -0
  9. package/src/emit/custom/customFlowS3.js +156 -0
  10. package/src/emit/custom/customFlowSteps.js +385 -0
  11. package/src/emit/custom/customFlowTemplates.js +28 -0
  12. package/src/emit/custom/customFlows.js +48 -19
  13. package/src/emit/custom/emitCustomFlowApplicationArtifacts.js +57 -692
  14. package/src/emit/custom/generateCustomFlowApplicationArtifacts.js +27 -25
  15. package/src/emit/error/emitErrorSchemas.js +73 -0
  16. package/src/emit/error/templates/errorSchema.ejs +8 -0
  17. package/src/emit/rbac/generateCreateTargetRoleHandler.js +11 -13
  18. package/src/emit/rbac/generateDynamicRbacFlowSchemas.js +14 -18
  19. package/src/emit/relationship/generateDynamicRelationshipFlowSchemas.js +16 -19
  20. package/src/emit/relationship/generateRelationshipApplicationArtifacts.js +19 -19
  21. package/src/emit/resource/dynamoResourceArtifacts.js +18 -0
  22. package/src/emit/resource/emitResourceArtifacts.js +13 -1247
  23. package/src/emit/resource/generateResourceArtifacts.js +20 -20
  24. package/src/emit/resource/iamResourceArtifacts.js +612 -0
  25. package/src/emit/resource/resourceState.js +564 -0
  26. package/src/emit/resource/resourceTemplate.js +30 -0
  27. package/src/emit/resource/s3ResourceArtifacts.js +14 -0
  28. package/src/emit/resource/sqsResourceArtifacts.js +113 -0
  29. package/src/emit/shared/runSubsystemGeneration.js +55 -0
  30. package/src/emit/system/emitSystemWebSocketArtifacts.js +2 -1
  31. package/src/generate.js +37 -4
  32. package/test/crudApplicationArtifacts.test.js +72 -0
  33. package/test/customFlowApplicationArtifacts.test.js +98 -0
  34. package/test/errorSchemas.test.js +154 -0
  35. package/test/publicApi.test.js +1 -1
  36. package/test/resourceArtifacts.test.js +99 -0
@@ -672,6 +672,105 @@ test('emits SQS queues and deduplicated IAM policies when generateCodeTag is an
672
672
  assert.strictEqual(notifyTopicMatches?.length, 1);
673
673
  });
674
674
 
675
+ test('rejects flow schema with event generateCode missing generatedCodeConfig', async () => {
676
+ const rootPath = await createProject();
677
+ const flowDirectory = join(rootPath, 'app/src/schemas/FlowSchemas');
678
+ await writeFile(
679
+ join(flowDirectory, 'MissingConfig.js'),
680
+ "export default { flowTag: 'missingConfig', event: ['generateCode'] };\n"
681
+ );
682
+
683
+ await assert.rejects(
684
+ generateResourceArtifacts(rootPath),
685
+ /flow with event 'generateCode' requires generatedCodeConfig/
686
+ );
687
+ });
688
+
689
+ test('rejects flow schema with event generateCode and invalid invocationType', async () => {
690
+ const rootPath = await createProject();
691
+ const flowDirectory = join(rootPath, 'app/src/schemas/FlowSchemas');
692
+ await writeFile(
693
+ join(flowDirectory, 'InvalidInvocation.js'),
694
+ "export default { flowTag: 'invalidInvocation', event: ['generateCode'], " +
695
+ "generatedCodeConfig: { invocationType: 'invalidType' } };\n"
696
+ );
697
+
698
+ await assert.rejects(
699
+ generateResourceArtifacts(rootPath),
700
+ /invocationType 'invalidType' is invalid/
701
+ );
702
+ });
703
+
704
+ test('emits SQS resources, SNS topics, and IAM role when flow has event generateCode with invocationType ownTopic', async () => {
705
+ const rootPath = await createProject();
706
+ const schemas = join(rootPath, 'app/src/schemas');
707
+ await writeFile(
708
+ join(schemas, 'FlowSchemas/GenOwnHook.js'),
709
+ "export default { flowTag: 'genOwnHook', event: ['generateCode'], " +
710
+ "generatedCodeConfig: { generateCodeTag: 'create', codeHookTag: 'before', " +
711
+ "invocationType: 'ownTopic' }, objType: { objectType: 'order' } };\n"
712
+ );
713
+ await generateResourceArtifacts(rootPath);
714
+
715
+ const crudResources = await readFile(
716
+ join(
717
+ rootPath,
718
+ 'resource/sls_yaml/generatedCode/source/generated-sns-sqs-crud.yml'
719
+ ),
720
+ 'utf8'
721
+ );
722
+ assert.match(crudResources, /^ CreateBeforeHookCallbackHdrSqs:/m);
723
+
724
+ const customResources = await readFile(
725
+ join(
726
+ rootPath,
727
+ 'resource/sls_yaml/generatedCode/source/generated-sns-sqs-custom-flows.yml'
728
+ ),
729
+ 'utf8'
730
+ );
731
+ assert.match(customResources, /^ GenOwnHookHdrSqs:/m);
732
+ assert.match(customResources, /^ InGenOwnHook:/m);
733
+
734
+ const iam = await readFile(
735
+ join(
736
+ rootPath,
737
+ 'app/sls_yaml/generatedCode/source/generate-shared-resource.yml'
738
+ ),
739
+ 'utf8'
740
+ );
741
+ const flowRole = roleBlock(iam, 'FlowObjectsRole');
742
+ assert.match(flowRole, /CreateBeforeHookCallbackHdrSqs/);
743
+ assert.match(flowRole, /GenOwnHook_In/);
744
+
745
+ const customRole = roleBlock(iam, 'GenOwnHookRole');
746
+ assert.match(customRole, /GenOwnHookHdrSqs/);
747
+ assert.match(customRole, /GenOwnHook_In/);
748
+ });
749
+
750
+ test('emits lambda:InvokeFunction in FlowObjectsRole when flow has event generateCode with invocationType lambdaSyncInv', async () => {
751
+ const rootPath = await createProject();
752
+ const schemas = join(rootPath, 'app/src/schemas');
753
+ await writeFile(
754
+ join(schemas, 'FlowSchemas/GenSyncHook.js'),
755
+ "export default { flowTag: 'genSyncHook', event: ['generateCode'], " +
756
+ "generatedCodeConfig: { generateCodeTag: 'create', codeHookTag: 'before', " +
757
+ "invocationType: 'lambdaSyncInv' }, objType: { objectType: 'order' } };\n"
758
+ );
759
+ await generateResourceArtifacts(rootPath);
760
+
761
+ const iam = await readFile(
762
+ join(
763
+ rootPath,
764
+ 'app/sls_yaml/generatedCode/source/generate-shared-resource.yml'
765
+ ),
766
+ 'utf8'
767
+ );
768
+ const role = roleBlock(iam, 'FlowObjectsRole');
769
+ assert.match(role, /lambda:InvokeFunction/);
770
+ assert.match(role, /GenSyncHook/);
771
+ });
772
+
773
+
675
774
  function roleBlock(iam, roleName) {
676
775
  const match = iam.match(
677
776
  new RegExp(