@izara_project/izara-core-generate-service-code 1.0.68 → 1.0.70

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 (129) hide show
  1. package/package.json +1 -1
  2. package/scripts/format-ejs.js +36 -32
  3. package/src/compile/compileProject.js +26 -10
  4. package/src/compile/loadSchemas.js +122 -59
  5. package/src/emit/coreFunction/emitCoreFunctionArtifacts.js +163 -0
  6. package/src/emit/coreFunction/templates/CoreFunction_Yaml.ejs +38 -0
  7. package/src/emit/coreFunction/templates/CoreResource_Yaml.ejs +235 -0
  8. package/src/emit/coreFunction/templates/GenerateSeedDataDynamo_HdrInv.ejs +16 -0
  9. package/src/emit/coreFunction/templates/GenerateSeedDataDynamo_Main.ejs +38 -0
  10. package/src/emit/coreFunction/templates/GenerateSeedDataGraphData_HdrInv.ejs +16 -0
  11. package/src/emit/coreFunction/templates/GenerateSeedDataGraphData_Main.ejs +32 -0
  12. package/src/emit/coreFunction/templates/GenerateSeedDataGraphSchema_HdrInv.ejs +16 -0
  13. package/src/emit/coreFunction/templates/GenerateSeedDataGraphSchema_Main.ejs +71 -0
  14. package/src/emit/coreFunction/templates/GeneratedGraphNodeSchemas.ejs +47 -0
  15. package/src/emit/coreFunction/templates/GeneratedGraphRelSchemas.ejs +27 -0
  16. package/src/emit/coreFunction/templates/GeneratedTableConfigs.ejs +34 -0
  17. package/src/emit/coreFunction/templates/InitialSetupConfig.ejs +108 -0
  18. package/src/emit/coreFunction/templates/InitialSetup_HdrInv.ejs +12 -0
  19. package/src/emit/coreFunction/templates/InitialSetup_Main.ejs +51 -0
  20. package/src/emit/coreFunction/templates/RemoveSeedDataDynamo_HdrInv.ejs +16 -0
  21. package/src/emit/coreFunction/templates/RemoveSeedDataDynamo_Main.ejs +31 -0
  22. package/src/emit/coreFunction/templates/UploadSchema_HdrInv.ejs +37 -0
  23. package/src/emit/coreFunction/templates/UploadSchema_Main.ejs +52 -0
  24. package/src/emit/crud/emitCrudApplicationArtifacts.js +194 -41
  25. package/src/emit/crud/emitDynamicCrudFlowSchemas.js +34 -17
  26. package/src/emit/crud/generateCrudApplicationArtifacts.js +14 -6
  27. package/src/emit/crud/generateDynamicCrudFlowSchemas.js +4 -1
  28. package/src/emit/crud/templates/CreateEndpoint_Main.ejs +1 -1
  29. package/src/emit/crud/templates/DeleteEndpoint_Main.ejs +1 -1
  30. package/src/emit/crud/templates/GetEndpoint_Main.ejs +2 -2
  31. package/src/emit/crud/templates/GetRangeEndpoint_Main.ejs +1 -1
  32. package/src/emit/crud/templates/UpdateEndpoint_Main.ejs +1 -1
  33. package/src/emit/custom/customFlows.js +23 -13
  34. package/src/emit/custom/emitCustomFlowApplicationArtifacts.js +535 -114
  35. package/src/emit/custom/generateCustomFlowApplicationArtifacts.js +28 -8
  36. package/src/emit/custom/templates/FlowEndpoint_Main.ejs +2 -2
  37. package/src/emit/custom/templates/FlowStep_Main.ejs +1 -1
  38. package/src/emit/custom/templates/s3/CreateObject_Main.ejs +1 -1
  39. package/src/emit/custom/templates/s3/FlowHandler_HdrS3.ejs +2 -2
  40. package/src/emit/custom/templates/s3/ReservedLimit_HdrSqs.ejs +1 -1
  41. package/src/emit/custom/templates/s3/ReservedLimit_Main.ejs +1 -1
  42. package/src/emit/custom/templates/triggerCache/CheckTriggerCache_HdrSqs.ejs +4 -4
  43. package/src/emit/function/functionYamlArtifact.js +273 -97
  44. package/src/emit/function/templates/ApiFunction_Yaml.ejs +7 -0
  45. package/src/emit/function/templates/EventBridgeFunction_Yaml.ejs +6 -0
  46. package/src/emit/function/templates/InvFunction_Yaml.ejs +5 -0
  47. package/src/emit/function/templates/S3Function_Yaml.ejs +16 -0
  48. package/src/emit/function/templates/SqsFunction_Yaml.ejs +10 -0
  49. package/src/emit/function/templates/WbsFunction_Yaml.ejs +10 -0
  50. package/src/emit/rbac/emitDynamicRbacFlowSchemas.js +28 -30
  51. package/src/emit/rbac/emitRbacApplicationArtifacts.js +6 -6
  52. package/src/emit/rbac/generateCreateTargetRoleHandler.js +6 -4
  53. package/src/emit/rbac/generateDynamicRbacFlowSchemas.js +8 -2
  54. package/src/emit/rbac/rbacFlowTag.js +3 -1
  55. package/src/emit/rbac/templates/UserRbacFlow_Main.ejs +1 -1
  56. package/src/emit/relationship/emitDynamicRelationshipFlowSchemas.js +26 -10
  57. package/src/emit/relationship/emitRelationshipApplicationArtifacts.js +189 -37
  58. package/src/emit/relationship/generateDynamicRelationshipFlowSchemas.js +8 -2
  59. package/src/emit/relationship/generateRelationshipApplicationArtifacts.js +15 -6
  60. package/src/emit/relationship/templates/ChangeRelationship_Main.ejs +1 -1
  61. package/src/emit/relationship/templates/CreateRelationship_Main.ejs +1 -1
  62. package/src/emit/relationship/templates/DeleteRelationship_Main.ejs +1 -1
  63. package/src/emit/relationship/templates/GetRelationship_Main.ejs +1 -1
  64. package/src/emit/relationship/templates/MoveRelationship_Main.ejs +1 -1
  65. package/src/emit/relationship/templates/UpdateRelationship_Main.ejs +1 -1
  66. package/src/emit/resource/emitResourceArtifacts.js +249 -123
  67. package/src/emit/resource/generateResourceArtifacts.js +15 -6
  68. package/src/emit/resource/templates/DynamoDBTable_Yaml.ejs +18 -18
  69. package/src/emit/resource/templates/FlowOut_Yaml.ejs +5 -5
  70. package/src/emit/resource/templates/GeneratedLambdaRoleServiceConfig.ejs +10 -9
  71. package/src/emit/resource/templates/ResourceBeforeLogicalYaml.ejs +44 -44
  72. package/src/emit/resource/templates/ResourceSqsYaml.ejs +36 -36
  73. package/src/emit/resource/templates/ResourceYaml.ejs +48 -48
  74. package/src/emit/resource/templates/S3Subscription_Yaml.ejs +7 -0
  75. package/src/emit/resource/templates/SharedResource_Yaml.ejs +11 -11
  76. package/src/emit/resource/templates/SystemDynamoDB_Yaml.ejs +122 -105
  77. package/src/emit/resource/templates/WebSocketSubscription_Yaml.ejs +7 -0
  78. package/src/emit/shared/templates/FindData_HdrSqs.ejs +120 -0
  79. package/src/emit/shared/templates/FindData_Main.ejs +345 -0
  80. package/src/emit/{crud → shared}/templates/FlowHandler_HdrApi.ejs +1 -1
  81. package/src/emit/{relationship → shared}/templates/FlowHandler_HdrDsq.ejs +4 -4
  82. package/src/emit/{crud → shared}/templates/FlowHandler_HdrInv.ejs +1 -1
  83. package/src/emit/{crud → shared}/templates/FlowHandler_HdrSqs.ejs +4 -4
  84. package/src/emit/shared/templates/PaginateProcessLogical_HdrDsq.ejs +162 -0
  85. package/src/emit/shared/templates/PaginateProcessLogical_HdrSqs.ejs +140 -0
  86. package/src/emit/shared/templates/PaginateProcessLogical_Main.ejs +268 -0
  87. package/src/emit/{relationship/templates/FlowHandler_HdrSqs.ejs → shared/templates/ProcessLogical_HdrSqs.ejs} +40 -55
  88. package/src/emit/shared/templates/ProcessLogical_Main.ejs +448 -0
  89. package/src/emit/system/emitSystemFindDataArtifacts.js +266 -0
  90. package/src/emit/system/emitSystemWebSocketArtifacts.js +61 -165
  91. package/src/emit/system/templates/WebSocketComplete_HdrSqs.ejs +48 -0
  92. package/src/emit/system/templates/WebSocketComplete_Main.ejs +91 -0
  93. package/src/emit/system/templates/WebSocketComplete_Yaml.ejs +19 -0
  94. package/src/emit/system/templates/WebSocketConnect.ejs +45 -0
  95. package/src/emit/system/templates/WebSocketConnect_Yaml.ejs +11 -0
  96. package/src/generate.js +166 -36
  97. package/src/generateIntTest.js +76 -28
  98. package/src/generateResourceIntTest.js +35 -12
  99. package/src/generateResources/IntTest/generateResources/generateResources.js +5 -2
  100. package/src/generateResources/IntTest/generateResources/templateResources.ejs +18 -30
  101. package/src/generateResources/IntTest/generateTests/events/events.js +1 -1
  102. package/src/generateResources/IntTest/generateTests/events/templateEvents.ejs +13 -10
  103. package/src/generateResources/IntTest/generateTests/generateTemplate.js +2 -2
  104. package/src/generateResources/IntTest/generateTests/pathIntTest/pathIntTest.js +2 -1
  105. package/src/generateResources/IntTest/generateTests/pathIntTest/template.ejs +1 -3
  106. package/src/generateResources/IntTest/generateTests/tests/templateTests.ejs +1 -1
  107. package/src/generateResources/IntTest/generateTests/tests/tests.js +7 -3
  108. package/src/generateResources/IntTest/libs/{libs.js → IntTestGenerateLib.js} +34 -23
  109. package/src/generateResources/IntTest/upload/uploadIntTest.js +33 -19
  110. package/src/intTestGeneratorShared.js +15 -10
  111. package/src/output/commitArtifacts.js +99 -39
  112. package/src/output/mergeHooks.js +34 -21
  113. package/src/output/validateArtifacts.js +37 -27
  114. package/src/plan/buildGenerationPlan.js +24 -13
  115. package/test/core.test.js +117 -58
  116. package/test/createTargetRoleHandler.test.js +1 -1
  117. package/test/crudApplicationArtifacts.test.js +132 -31
  118. package/test/customFlowApplicationArtifacts.test.js +353 -71
  119. package/test/dynamicCrudFlowSchemas.test.js +74 -26
  120. package/test/dynamicRbacFlowSchemas.test.js +61 -14
  121. package/test/dynamicRelationshipFlowSchemas.test.js +65 -18
  122. package/test/functionYamlArtifact.test.js +67 -10
  123. package/test/intTestApi.test.js +9 -10
  124. package/test/publicApi.test.js +178 -36
  125. package/test/relationshipApplicationArtifacts.test.js +90 -19
  126. package/test/resourceArtifacts.test.js +173 -33
  127. package/src/emit/relationship/dynamicRelationshipFlowSchemaTemplate.js +0 -11
  128. package/src/emit/relationship/templates/FlowHandler_HdrApi.ejs +0 -59
  129. package/src/emit/relationship/templates/FlowHandler_HdrInv.ejs +0 -47
@@ -4,51 +4,119 @@ import { tmpdir } from 'node:os';
4
4
  import { join } from 'node:path';
5
5
  import test, { after } from 'node:test';
6
6
 
7
+ process.env.NODE_ENV = 'test';
8
+
7
9
  import { generateResourceArtifacts } from '../src/emit/resource/generateResourceArtifacts.js';
8
10
 
9
11
  const roots = new Set();
10
- after(() => Promise.all([...roots].map(root => rm(root, { recursive: true, force: true }))));
12
+ after(() =>
13
+ Promise.all(
14
+ [...roots].map((root) => rm(root, { recursive: true, force: true }))
15
+ )
16
+ );
11
17
 
12
18
  test('emits queues, topics, tables, and IAM roles from schema data', async () => {
13
19
  const rootPath = await createProject();
14
20
  const result = await generateResourceArtifacts(rootPath);
15
21
 
16
- assert.equal(result.files.length, 5);
17
- const resources = await readFile(join(rootPath, 'resource/sls_yaml/generatedCode/source/generated-sns-in-sqs.yml'), 'utf8');
22
+ assert.equal(result.files.length, 7);
23
+ const resources = await readFile(
24
+ join(
25
+ rootPath,
26
+ 'resource/sls_yaml/generatedCode/source/generated-sns-in-sqs.yml'
27
+ ),
28
+ 'utf8'
29
+ );
30
+ assert.match(
31
+ resources,
32
+ /SubscriptionOutCreateToUploadReservedLimitHdrSqs:/
33
+ );
34
+ assert.match(resources, /TopicArn: !Ref OutCreate/);
35
+ assert.match(
36
+ resources,
37
+ /Endpoint: "arn:aws:sqs:\${self:custom\.iz_region}:\${self:custom\.iz_accountId}:\${self:custom\.iz_resourcePrefix}UploadReservedLimitHdrSqs"/
38
+ );
18
39
  assert.match(resources, /InCreate:/);
19
- for (const queueName of ['FindDataHdrSqs', 'ProcessLogicalHdrSqs', 'PaginateProcessLogicalHdrDsq', 'PaginateProcessLogicalHdrSqs']) {
40
+ for (const queueName of [
41
+ 'FindDataHdrSqs',
42
+ 'ProcessLogicalHdrSqs',
43
+ 'PaginateProcessLogicalHdrDsq',
44
+ 'PaginateProcessLogicalHdrSqs'
45
+ ]) {
20
46
  assert.match(resources, new RegExp(`^ ${queueName}:`, 'm'));
21
47
  }
22
48
  assert.match(
23
- await readFile(join(rootPath, 'resource/sls_yaml/generatedCode/source/generated-dynamoDB-table.yml'), 'utf8'),
49
+ await readFile(
50
+ join(
51
+ rootPath,
52
+ 'resource/sls_yaml/generatedCode/source/generated-dynamoDB-table.yml'
53
+ ),
54
+ 'utf8'
55
+ ),
24
56
  /OrdersTable:/
25
57
  );
26
- const iam = await readFile(join(rootPath, 'app/sls_yaml/generatedCode/source/generate-shared-resource.yml'), 'utf8');
58
+ const iam = await readFile(
59
+ join(
60
+ rootPath,
61
+ 'app/sls_yaml/generatedCode/source/generate-shared-resource.yml'
62
+ ),
63
+ 'utf8'
64
+ );
27
65
  assert.match(iam, /FlowObjectsRole:/);
28
66
  assert.match(iam, /FlowRelationshipRole:/);
29
67
  assert.match(iam, /FlowRbacRole:/);
30
68
  assert.match(iam, /sqs:ReceiveMessage/);
31
69
  assert.match(iam, /sns:Publish/);
32
- assert.doesNotMatch(roleBlock(iam, 'WebSocketMainRole'), /Orders|RolePermissions|CreateHdrSqs/);
33
- assert.match(roleBlock(iam, 'WebSocketMainRole'), /UserUploadRecords|WebSocketTask|WebSocketCompleteHdrSqs/);
34
- assert.doesNotMatch(roleBlock(iam, 'FlowRbacRole'), /Orders|ProcessCreateRelationshipHdrSqs/);
35
- assert.match(roleBlock(iam, 'FlowRbacRole'), /RolePermissions|ProcessCreateTargetRoleHdrSqs/);
70
+ assert.doesNotMatch(
71
+ roleBlock(iam, 'WebSocketMainRole'),
72
+ /Orders|RolePermissions|CreateHdrSqs/
73
+ );
74
+ assert.match(
75
+ roleBlock(iam, 'WebSocketMainRole'),
76
+ /UserUploadRecords|WebSocketTask|WebSocketCompleteHdrSqs/
77
+ );
78
+ assert.doesNotMatch(
79
+ roleBlock(iam, 'FlowRbacRole'),
80
+ /Orders|ProcessCreateRelationshipHdrSqs/
81
+ );
82
+ assert.match(
83
+ roleBlock(iam, 'FlowRbacRole'),
84
+ /RolePermissions|ProcessCreateTargetRoleHdrSqs/
85
+ );
36
86
  assert.match(resources, /^ CreateRelationshipHdrSqs:/m);
37
- assert.equal((resources.match(/^ CreateRelationshipHdrSqs:/gm) ?? []).length, 1);
87
+ assert.equal(
88
+ (resources.match(/^ CreateRelationshipHdrSqs:/gm) ?? []).length,
89
+ 1
90
+ );
38
91
  assert.match(resources, /^ CreateRelationshipCompleteHdrSqs:/m);
39
92
  assert.match(resources, /^ GetRelationshipHdrDsq:/m);
40
- assert.doesNotMatch(resources, /Process(?:Create|Update|Delete|Get|Change|Move)Relationship/);
93
+ assert.doesNotMatch(
94
+ resources,
95
+ /Process(?:Create|Update|Delete|Get|Change|Move)Relationship/
96
+ );
41
97
  const relationshipRole = roleBlock(iam, 'FlowRelationshipRole');
42
98
  assert.match(relationshipRole, /CreateRelationshipHdrSqs/);
43
99
  assert.match(relationshipRole, /CreateRelationshipCompleteHdrSqs/);
44
100
  assert.match(relationshipRole, /GetRelationshipHdrDsq/);
45
- assert.doesNotMatch(relationshipRole, /Process(?:Create|Update|Delete|Get|Change|Move)Relationship/);
101
+ assert.doesNotMatch(
102
+ relationshipRole,
103
+ /Process(?:Create|Update|Delete|Get|Change|Move)Relationship/
104
+ );
46
105
  assert.match(roleBlock(iam, 'RegisterRole'), /s3:GetObject/);
47
106
  assert.doesNotMatch(roleBlock(iam, 'RegisterRole'), /dynamodb:|sqs:|sns:/);
48
- assert.doesNotMatch(iam, /s3:GetObjectVersion|s3:ListBucket|sqs:DeleteMessageBatch|sqs:GetQueueUrl/);
107
+ assert.doesNotMatch(
108
+ iam,
109
+ /s3:GetObjectVersion|s3:ListBucket|sqs:DeleteMessageBatch|sqs:GetQueueUrl/
110
+ );
49
111
  assert.match(iam, /#<#\/\w+StatementHookCode#>\n\n \w+Role:/);
50
112
 
51
- const lambdaRoleConfig = await readFile(join(rootPath, 'app/initial_setup/generatedCode/source/generatedLambdaRoleServiceConfig.js'), 'utf8');
113
+ const lambdaRoleConfig = await readFile(
114
+ join(
115
+ rootPath,
116
+ 'app/initial_setup/generatedCode/source/generatedLambdaRoleServiceConfig.js'
117
+ ),
118
+ 'utf8'
119
+ );
52
120
  assert.match(lambdaRoleConfig, /roleName: 'FlowObjects'/);
53
121
  assert.match(lambdaRoleConfig, /roleName: 'ProcFindData'/);
54
122
  assert.match(lambdaRoleConfig, /roleName: 'FlowRelationship'/);
@@ -63,7 +131,10 @@ test('emits queues, topics, tables, and IAM roles from schema data', async () =>
63
131
  'app/sls_yaml/generatedCode/source/generate-shared-resource.yml',
64
132
  'app/initial_setup/generatedCode/source/generatedLambdaRoleServiceConfig.js'
65
133
  ]) {
66
- assert.doesNotMatch(await readFile(join(rootPath, filePath), 'utf8'), /\n\n$/);
134
+ assert.doesNotMatch(
135
+ await readFile(join(rootPath, filePath), 'utf8'),
136
+ /\n\n$/
137
+ );
67
138
  }
68
139
  });
69
140
 
@@ -77,8 +148,17 @@ test('emits one before-logical queue for flows that share an action', async () =
77
148
 
78
149
  await generateResourceArtifacts(rootPath);
79
150
 
80
- const resources = await readFile(join(rootPath, 'resource/sls_yaml/generatedCode/source/generated-sns-in-sqs.yml'), 'utf8');
81
- assert.equal((resources.match(/^ CreateBeforeLogicalHdrSqs:/gm) ?? []).length, 1);
151
+ const resources = await readFile(
152
+ join(
153
+ rootPath,
154
+ 'resource/sls_yaml/generatedCode/source/generated-sns-in-sqs.yml'
155
+ ),
156
+ 'utf8'
157
+ );
158
+ assert.equal(
159
+ (resources.match(/^ CreateBeforeLogicalHdrSqs:/gm) ?? []).length,
160
+ 1
161
+ );
82
162
  assert.match(resources, /SubscriptionOutFirstToCreateBeforeLogical:/);
83
163
  assert.match(resources, /SubscriptionOutSecondToCreateBeforeLogical:/);
84
164
  });
@@ -87,45 +167,105 @@ test('emits the shared WebSocket completion queue and output-topic subscriptions
87
167
  const rootPath = await createProject();
88
168
  await generateResourceArtifacts(rootPath);
89
169
 
90
- const resources = await readFile(join(rootPath, 'resource/sls_yaml/generatedCode/source/generated-sns-in-sqs.yml'), 'utf8');
170
+ const resources = await readFile(
171
+ join(
172
+ rootPath,
173
+ 'resource/sls_yaml/generatedCode/source/generated-sns-in-sqs.yml'
174
+ ),
175
+ 'utf8'
176
+ );
91
177
  assert.match(resources, /^ WebSocketCompleteHdrSqs:/m);
92
178
  assert.match(resources, /SubscriptionToOutCustomWebSocketComplete:/);
93
- const iam = await readFile(join(rootPath, 'app/sls_yaml/generatedCode/source/generate-shared-resource.yml'), 'utf8');
94
- for (const roleName of ['WebSocketMainRole', 'FlowObjectsRole', 'FlowRelationshipRole', 'FlowRbacRole', 'CustomRole', 'UploadRole']) {
179
+ const iam = await readFile(
180
+ join(
181
+ rootPath,
182
+ 'app/sls_yaml/generatedCode/source/generate-shared-resource.yml'
183
+ ),
184
+ 'utf8'
185
+ );
186
+ for (const roleName of [
187
+ 'WebSocketMainRole',
188
+ 'FlowObjectsRole',
189
+ 'FlowRelationshipRole',
190
+ 'FlowRbacRole',
191
+ 'CustomRole',
192
+ 'UploadRole'
193
+ ]) {
95
194
  const role = roleBlock(iam, roleName);
96
195
  assert.match(role, /execute-api:ManageConnections/);
97
- assert.match(role, /arn:aws:execute-api:\$\{self:custom\.iz_region\}:\$\{self:custom\.iz_accountId\}:\*\/\*/);
196
+ assert.match(
197
+ role,
198
+ /arn:aws:execute-api:\$\{self:custom\.iz_region\}:\$\{self:custom\.iz_accountId\}:\*\/\*/
199
+ );
98
200
  }
99
- assert.match(resources, /SubscriptionToOutCreateRelationshipWebSocketComplete:/);
201
+ assert.match(
202
+ resources,
203
+ /SubscriptionToOutCreateRelationshipWebSocketComplete:/
204
+ );
100
205
  });
101
206
 
102
207
  test('scopes stored-cache permissions to the flow object table', async () => {
103
208
  const rootPath = await createProject();
104
- await writeFile(join(rootPath, 'app/src/schemas/ObjectSchemas/Cache.js'), "export default { objectType: 'cache', storageResources: { main: { storageType: 'dynamoDB', tableName: 'CurrentData' } } };\n");
105
- await writeFile(join(rootPath, 'app/src/schemas/FlowSchemas/Cache.js'), "export default { flowTag: 'cacheFlow', event: ['lambdaSyncApi'], statusType: 'storedCache', objType: { objectType: 'cache' } };\n");
209
+ await writeFile(
210
+ join(rootPath, 'app/src/schemas/ObjectSchemas/Cache.js'),
211
+ "export default { objectType: 'cache', storageResources: { main: { storageType: 'dynamoDB', tableName: 'CurrentData' } } };\n"
212
+ );
213
+ await writeFile(
214
+ join(rootPath, 'app/src/schemas/FlowSchemas/Cache.js'),
215
+ "export default { flowTag: 'cacheFlow', event: ['lambdaSyncApi'], statusType: 'storedCache', objType: { objectType: 'cache' } };\n"
216
+ );
106
217
 
107
218
  await generateResourceArtifacts(rootPath);
108
219
 
109
- const iam = await readFile(join(rootPath, 'app/sls_yaml/generatedCode/source/generate-shared-resource.yml'), 'utf8');
220
+ const iam = await readFile(
221
+ join(
222
+ rootPath,
223
+ 'app/sls_yaml/generatedCode/source/generate-shared-resource.yml'
224
+ ),
225
+ 'utf8'
226
+ );
110
227
  const role = roleBlock(iam, 'CacheFlowRole');
111
228
  assert.match(role, /CurrentData/);
112
229
  assert.doesNotMatch(role, /Orders|WebSocketTask/);
113
230
  });
114
231
 
115
232
  function roleBlock(iam, roleName) {
116
- const match = iam.match(new RegExp(`^ ${roleName}:\\n(?:(?!^ [A-Za-z][A-Za-z0-9]*Role:\\n)[\\s\\S])*`, 'm'));
233
+ const match = iam.match(
234
+ new RegExp(
235
+ `^ ${roleName}:\\n(?:(?!^ [A-Za-z][A-Za-z0-9]*Role:\\n)[\\s\\S])*`,
236
+ 'm'
237
+ )
238
+ );
117
239
  assert.ok(match, `Missing ${roleName} in generated IAM`);
118
240
  return match[0];
119
241
  }
120
242
 
121
243
  async function createProject() {
122
- const rootPath = await mkdtemp(join(tmpdir(), 'generate-service-code-v2-resource-'));
244
+ const rootPath = await mkdtemp(
245
+ join(tmpdir(), 'generate-service-code-v2-resource-')
246
+ );
123
247
  roots.add(rootPath);
124
248
  const schemas = join(rootPath, 'app/src/schemas');
125
- await Promise.all(['ObjectSchemas', 'RelationshipSchemas', 'FlowSchemas'].map(directory => mkdir(join(schemas, directory), { recursive: true })));
126
- await writeFile(join(schemas, 'ObjectSchemas/Order.js'), "export default { objectType: 'order', generatedBy: 'userGenerated', addOnDataStructure: [{ type: 'rbac' }], identifiers: [{ type: 'partitionKey', fieldName: 'orderId' }], storageResources: { main: { storageType: 'dynamoDB', tableName: 'Orders' } } };\n");
127
- await writeFile(join(schemas, 'RelationshipSchemas/OrderCustomer.js'), "export default { relationshipTag: 'orderCustomer', links: [] };\n");
128
- await writeFile(join(schemas, 'FlowSchemas/Custom.js'), "export default { flowTag: 'custom', event: ['ownTopic'], outputTopic: true };\n");
129
- await writeFile(join(schemas, 'FlowSchemas/Upload.js'), "export default { flowTag: 'upload', event: ['s3'] };\n");
249
+ await Promise.all(
250
+ ['ObjectSchemas', 'RelationshipSchemas', 'FlowSchemas'].map((directory) =>
251
+ mkdir(join(schemas, directory), { recursive: true })
252
+ )
253
+ );
254
+ await writeFile(
255
+ join(schemas, 'ObjectSchemas/Order.js'),
256
+ "export default { objectType: 'order', generatedBy: 'userGenerated', addOnDataStructure: [{ type: 'rbac' }], identifiers: [{ type: 'partitionKey', fieldName: 'orderId' }], storageResources: { main: { storageType: 'dynamoDB', tableName: 'Orders' } } };\n"
257
+ );
258
+ await writeFile(
259
+ join(schemas, 'RelationshipSchemas/OrderCustomer.js'),
260
+ "export default { relationshipTag: 'orderCustomer', links: [] };\n"
261
+ );
262
+ await writeFile(
263
+ join(schemas, 'FlowSchemas/Custom.js'),
264
+ "export default { flowTag: 'custom', event: ['ownTopic'], outputTopic: true };\n"
265
+ );
266
+ await writeFile(
267
+ join(schemas, 'FlowSchemas/Upload.js'),
268
+ "export default { flowTag: 'upload', event: ['s3'], s3Subscription: { topicName: 'OutCreate', queueName: 'UploadReservedLimitHdrSqs' } };\n"
269
+ );
130
270
  return rootPath;
131
271
  }
@@ -1,11 +0,0 @@
1
- export function renderDynamicRelationshipFlowSchema(action, flow) {
2
- return [
3
- '/**',
4
- ' * GENERATED DYNAMIC RELATIONSHIP FLOW SCHEMA',
5
- ` * Action: ${action}`,
6
- ' * Description: Handles dynamic relationship actions for all allowed RelationshipTypes via SQS/DSQ',
7
- ' */',
8
- `export default ${JSON.stringify(flow, null, 2)};`,
9
- ''
10
- ].join('\n');
11
- }
@@ -1,59 +0,0 @@
1
- import {
2
- middlewareHandler as middleware,
3
- response
4
- } from '@izara_project/izara-middleware';
5
- import callingFlowSharedLib from '@izara_project/izara-core-library-calling-flow';
6
-
7
- import <%= functionName %> from './<%= mainFileName %>.js';
8
-
9
- const validatorSchema = {
10
- //(<validatorSchema>)
11
- <% if (typeof startConfig !== 'undefined' && startConfig !== null && startConfig.properties && startConfig.properties.length > 0) { -%>
12
- type: 'object',
13
- properties: {
14
- <% startConfig.properties.forEach(prop => { -%>
15
- <%- prop.propertyName %>: { type: '<%- prop.type || 'string' %>' }
16
- <% }) -%>
17
- },
18
- required: [<%- startConfig.properties.filter(p => p.required !== false).map(p => `'${p.propertyName}'`).join(', ') %>]
19
- <% } -%>
20
- //(</validatorSchema>)
21
- };
22
-
23
- middleware.setValidatorSchema(validatorSchema, { noAuthorizer: true });
24
-
25
- /**
26
- * GENERATED HANDLER: <%= flowStepName %> (Flow: <%= flowTag %>)
27
- * Triggered by: API Gateway
28
- */
29
- export const main = middleware.wrap(async (event, context) => {
30
- event._izContext?.logger?.debug(
31
- `[${context.awsRequestId}] Received API request in <%= flowStepName %>`
32
- );
33
-
34
- try {
35
- const passOnProperties = [
36
- event.body,
37
- //(<additionalParams>)
38
- //(</additionalParams>)
39
- callingFlowSharedLib.addCallingFlowToPassOnProperties(event)
40
- ];
41
-
42
- const lambdaFunctionResponse = await <%= functionName %>(
43
- event._izContext,
44
- ...passOnProperties
45
- );
46
-
47
- if (lambdaFunctionResponse instanceof Error) {
48
- return response.failure(lambdaFunctionResponse);
49
- }
50
-
51
- return response.success(lambdaFunctionResponse);
52
- } catch (err) {
53
- event._izContext?.logger?.error(
54
- 'Unhandled Error in <%= flowStepName %> API:',
55
- err
56
- );
57
- return response.failure(err);
58
- }
59
- });
@@ -1,47 +0,0 @@
1
- import { middlewareHandler as middleware } from '@izara_project/izara-middleware';
2
- import callingFlowSharedLib from '@izara_project/izara-core-library-calling-flow';
3
-
4
- import <%= functionName %> from './<%= mainFileName %>.js';
5
-
6
- const validatorSchema = {
7
- //(<validatorSchema>)
8
- <% if (typeof startConfig !== 'undefined' && startConfig !== null && startConfig.properties && startConfig.properties.length > 0) { -%>
9
- type: 'object',
10
- properties: {
11
- <% startConfig.properties.forEach(prop => { -%>
12
- <%- prop.propertyName %>: { type: '<%- prop.type || 'string' %>' }
13
- <% }) -%>
14
- },
15
- required: [<%- startConfig.properties.filter(p => p.required !== false).map(p => `'${p.propertyName}'`).join(', ') %>]
16
- <% } -%>
17
- //(</validatorSchema>)
18
- };
19
-
20
- middleware.setValidatorSchema(validatorSchema);
21
-
22
- /**
23
- * GENERATED HANDLER: <%= flowStepName %> (Flow: <%= flowTag %>)
24
- * Triggered by: Lambda Invocation
25
- */
26
- export const main = middleware.wrap(async (event, context) => {
27
- event._izContext?.logger?.debug(
28
- `[${context.awsRequestId}] Received Invocation in <%= flowStepName %>`
29
- );
30
-
31
- try {
32
- const passOnProperties = [
33
- event,
34
- //(<additionalParams>)
35
- //(</additionalParams>)
36
- callingFlowSharedLib.addCallingFlowToPassOnProperties(event)
37
- ];
38
-
39
- return await <%= functionName %>(event._izContext, ...passOnProperties);
40
- } catch (err) {
41
- event._izContext?.logger?.error(
42
- 'Unhandled Error in <%= flowStepName %> Invocation:',
43
- err
44
- );
45
- throw err;
46
- }
47
- });