@izara_project/izara-core-generate-service-code 1.0.71 → 1.0.73

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 (67) hide show
  1. package/package.json +4 -3
  2. package/src/compile/loadSchemas.js +69 -1
  3. package/src/emit/coreFunction/emitCoreFunctionArtifacts.js +171 -44
  4. package/src/emit/coreFunction/templates/GenerateSeedDataDynamo_HdrInv.ejs +4 -1
  5. package/src/emit/coreFunction/templates/GenerateSeedDataGraphData_HdrInv.ejs +4 -1
  6. package/src/emit/coreFunction/templates/GenerateSeedDataGraphSchema_HdrInv.ejs +4 -1
  7. package/src/emit/coreFunction/templates/GenerateSeedDataGraphSchema_Main.ejs +10 -2
  8. package/src/emit/coreFunction/templates/GeneratedGraphNodeSchemas.ejs +17 -17
  9. package/src/emit/coreFunction/templates/GeneratedGraphRelSchemas.ejs +6 -6
  10. package/src/emit/coreFunction/templates/GeneratedTableConfigs.ejs +12 -12
  11. package/src/emit/coreFunction/templates/InitialSetupConfig.ejs +195 -58
  12. package/src/emit/coreFunction/templates/InitialSetupRunner.ejs +177 -0
  13. package/src/emit/coreFunction/templates/InitialSetupRunner_initialSetup.ejs +9 -0
  14. package/src/emit/coreFunction/templates/InitialSetupRunner_seedDynamo.ejs +22 -0
  15. package/src/emit/coreFunction/templates/InitialSetupRunner_seedGraph.ejs +8 -0
  16. package/src/emit/coreFunction/templates/InitialSetupRunner_seedRemove.ejs +5 -0
  17. package/src/emit/coreFunction/templates/InitialSetupRunner_uploadSchema.ejs +33 -0
  18. package/src/emit/coreFunction/templates/InitialSetup_Main.ejs +9 -11
  19. package/src/emit/coreFunction/templates/UploadSchema_HdrInv.ejs +1 -3
  20. package/src/emit/coreFunction/templates/UploadSchema_Main.ejs +1 -1
  21. package/src/emit/crud/templates/CreateEndpoint_Main.ejs +1 -1
  22. package/src/emit/crud/templates/DeleteEndpoint_Main.ejs +1 -1
  23. package/src/emit/crud/templates/FlowMain_Wbs.ejs +1 -2
  24. package/src/emit/crud/templates/GetEndpoint_Main.ejs +1 -1
  25. package/src/emit/crud/templates/GetRangeEndpoint_Main.ejs +1 -1
  26. package/src/emit/crud/templates/UpdateEndpoint_Main.ejs +1 -1
  27. package/src/emit/custom/emitCustomFlowApplicationArtifacts.js +26 -6
  28. package/src/emit/custom/templates/FlowEndpoint_Main.ejs +2 -2
  29. package/src/emit/custom/templates/FlowStep_Main.ejs +1 -1
  30. package/src/emit/custom/templates/s3/CreateObject_Main.ejs +1 -1
  31. package/src/emit/custom/templates/s3/ReservedLimit_Main.ejs +1 -1
  32. package/src/emit/custom/templates/triggerCache/CheckTriggerCache_HdrSqs.ejs +13 -9
  33. package/src/emit/relationship/templates/ChangeRelationship_Main.ejs +1 -1
  34. package/src/emit/relationship/templates/CreateRelationship_Main.ejs +1 -1
  35. package/src/emit/relationship/templates/DeleteRelationship_Main.ejs +1 -1
  36. package/src/emit/relationship/templates/GetRelationship_Main.ejs +53 -32
  37. package/src/emit/relationship/templates/MoveRelationship_Main.ejs +1 -1
  38. package/src/emit/relationship/templates/UpdateRelationship_Main.ejs +1 -1
  39. package/src/emit/resource/emitResourceArtifacts.js +58 -17
  40. package/src/emit/resource/templates/DynamoDBTable_Yaml.ejs +18 -18
  41. package/src/emit/resource/templates/FlowOut_Yaml.ejs +5 -5
  42. package/src/emit/resource/templates/GeneratedLambdaRoleServiceConfig.ejs +9 -10
  43. package/src/emit/resource/templates/ResourceBeforeLogicalYaml.ejs +44 -44
  44. package/src/emit/resource/templates/ResourceSqsYaml.ejs +36 -36
  45. package/src/emit/resource/templates/ResourceYaml.ejs +48 -48
  46. package/src/emit/resource/templates/S3Bucket_Yaml.ejs +0 -1
  47. package/src/emit/resource/templates/S3Subscription_Yaml.ejs +6 -6
  48. package/src/emit/resource/templates/SharedResource_Yaml.ejs +4 -4
  49. package/src/emit/resource/templates/SystemDynamoDB_Yaml.ejs +115 -115
  50. package/src/emit/resource/templates/WebSocketSubscription_Yaml.ejs +6 -6
  51. package/src/emit/shared/templates/FindData_HdrSqs.ejs +1 -1
  52. package/src/emit/shared/templates/FlowHandler_HdrApi.ejs +9 -7
  53. package/src/emit/shared/templates/FlowHandler_HdrDsq.ejs +19 -12
  54. package/src/emit/shared/templates/FlowHandler_HdrInv.ejs +9 -7
  55. package/src/emit/shared/templates/FlowHandler_HdrSqs.ejs +19 -12
  56. package/src/emit/shared/templates/PaginateProcessLogical_HdrDsq.ejs +1 -1
  57. package/src/emit/shared/templates/PaginateProcessLogical_HdrSqs.ejs +1 -1
  58. package/src/emit/shared/templates/PaginateProcessLogical_Main.ejs +2 -2
  59. package/src/emit/shared/templates/ProcessLogical_HdrSqs.ejs +1 -1
  60. package/src/generate.js +26 -5
  61. package/src/output/mergeHooks.js +13 -13
  62. package/src/output/validateArtifacts.js +10 -1
  63. package/test/customFlowApplicationArtifacts.test.js +71 -0
  64. package/test/publicApi.test.js +2 -2
  65. package/test/resourceArtifacts.test.js +8 -18
  66. package/docs/TriggeredCache Flow.drawio +0 -193
  67. package/docs/TriggeredCacheFlow.mmd +0 -47
@@ -43,7 +43,7 @@ import dynamodbSharedLib from '@izara_project/izara-core-library-dynamodb';
43
43
  export default async function <%- mainFileName %>(
44
44
  _izContext,
45
45
  requestParams,
46
- callingFlowConfig = {},
46
+ callingFlowConfig = {}
47
47
  //(<additionalParams>)
48
48
  //(</additionalParams>)
49
49
  ) {
@@ -479,7 +479,7 @@ export async function <%- flowTag %>MainLogical(
479
479
  export default async function <%- flowTag %>(
480
480
  _izContext,
481
481
  requestParams,
482
- callingFlowConfig = {},
482
+ callingFlowConfig = {}
483
483
  //(<additionalParams>)
484
484
  //(</additionalParams>)
485
485
  ) {
@@ -657,11 +657,28 @@ function stepConfig(flow, step) {
657
657
  };
658
658
  }
659
659
 
660
- function mapFields(names = [], definitions = {}) {
661
- return names.map((name) => ({
662
- propertyName: name,
663
- ...(definitions?.[name] ?? {})
664
- }));
660
+ function mapFields(items = [], definitions = {}) {
661
+ return items.map((item) => {
662
+ if (typeof item === 'string') {
663
+ const def = definitions?.[item] ?? {};
664
+ return {
665
+ propertyName: item,
666
+ required: def.required ?? false,
667
+ ...def
668
+ };
669
+ }
670
+ if (typeof item === 'object' && item !== null) {
671
+ const name = item.key ?? item.propertyName;
672
+ const def = definitions?.[name] ?? {};
673
+ return {
674
+ propertyName: name,
675
+ required: item.required ?? def.required ?? false,
676
+ ...def,
677
+ ...item
678
+ };
679
+ }
680
+ return item;
681
+ });
665
682
  }
666
683
 
667
684
  function isS3Only(flow) {
@@ -690,7 +707,10 @@ function storedCacheTableName(flow, objects) {
690
707
  : candidates[0];
691
708
  return (
692
709
  Object.values(object?.storageResources ?? {}).find(
693
- (resource) => resource?.storageType === 'dynamoDB'
710
+ (resource) =>
711
+ resource?.storageType === 'dynamo' ||
712
+ resource?.storageType === 'dynamoDB' ||
713
+ !resource?.storageType
694
714
  )?.tableName ?? null
695
715
  );
696
716
  }
@@ -58,7 +58,7 @@ const { createFlowTypeConcat } = utils;
58
58
  export default async function <%- typeof functionName !== 'undefined' ? functionName : upperCaseFlowTag %>(
59
59
  _izContext,
60
60
  requestParams,
61
- callingFlowConfig = {},
61
+ callingFlowConfig = {}
62
62
  //(<additionalParams>)
63
63
  //(</additionalParams>)
64
64
  ) {
@@ -88,7 +88,7 @@ export default async function <%- typeof functionName !== 'undefined' ? function
88
88
  createFlowTypeConcat(_izContext, {
89
89
  flowTag: '<%= flowTag %>',
90
90
  serviceTag: process.env.iz_serviceTag
91
- }),
91
+ })
92
92
  //(<storedCacheConfig>)
93
93
  //(</storedCacheConfig>)
94
94
  );
@@ -37,7 +37,7 @@ import { identifierUuid } from '@izara_project/izara-shared-core';
37
37
  export default async function <%= functionName %>(
38
38
  _izContext,
39
39
  requestParams,
40
- callingFlowConfig = {},
40
+ callingFlowConfig = {}
41
41
  //(<additionalParams>)
42
42
  //(</additionalParams>)
43
43
  ) {
@@ -51,7 +51,7 @@ const { TOPIC_NAME_GENERATE_CODE } = schemaConsts;
51
51
  export default async function createObject(
52
52
  _izContext,
53
53
  requestParams,
54
- callingFlowConfig = {},
54
+ callingFlowConfig = {}
55
55
  //(<additionalParams>)
56
56
  //(</additionalParams>)
57
57
  ) {
@@ -56,7 +56,7 @@ export default async function reservedLimit(
56
56
  objInstanceFull,
57
57
  //(<additionalProperties>)
58
58
  //(</additionalProperties>)
59
- callingFlowConfig = {},
59
+ callingFlowConfig = {}
60
60
  ) {
61
61
  try {
62
62
  _izContext.logger.debug('----- reservedLimit event params ----- ', {
@@ -6,33 +6,37 @@ import callingFlowSharedLib from '@izara_project/izara-core-library-calling-flow
6
6
  import <%- functionName %> from './<%- functionName %>_Main.js';
7
7
 
8
8
  let perRecordsValidatorSchema = {
9
- <% if (typeof startConfig !== 'undefined' && startConfig !== null && startConfig.properties && startConfig.properties.length > 0) { -%>
9
+ <%_ if (typeof startConfig !== 'undefined' && startConfig !== null && startConfig.properties && startConfig.properties.length > 0) { _%>
10
10
  type: 'object',
11
11
  properties: {
12
- <% startConfig.properties.forEach((prop, index) => { %> <%- prop.propertyName %>: {
12
+ <%_ startConfig.properties.forEach((prop, index) => { _%>
13
+ <%- /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(prop.propertyName) ? prop.propertyName : `'${prop.propertyName}'` %>: {
13
14
  type: '<%- prop.type || 'string' %>'
14
- },
15
- <% }) %>
15
+ }<%- index < startConfig.properties.length - 1 ? ',' : '' %>
16
+ <%_ }) _%>
16
17
  },
17
18
  required: [<%- startConfig.properties.filter(p => p.required === true).map(p => `'${p.propertyName}'`).join(', ') %>]
18
- <% } -%>
19
+ <%_ } _%>
19
20
  };
20
21
 
21
- <% if (typeof startConfig !== 'undefined' && startConfig !== null && startConfig.messageAttributes && startConfig.messageAttributes.length > 0) { -%>
22
+ <%_ if (typeof startConfig !== 'undefined' && startConfig !== null && startConfig.messageAttributes && startConfig.messageAttributes.length > 0) { _%>
22
23
  let messageAttributeValidatorSchema = {
23
24
  type: 'object',
24
25
  properties: {
25
- <% startConfig.messageAttributes.forEach((prop, index) => { %> <%- prop.propertyName %>: {
26
+ <%_ startConfig.messageAttributes.forEach((prop, index) => { _%>
27
+ <%- /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(prop.propertyName) ? prop.propertyName : `'${prop.propertyName}'` %>: {
26
28
  type: 'object',
27
29
  properties: {
28
30
  Type: { type: 'string' },
29
31
  Value: { type: '<%- prop.type || 'string' %>' }
30
32
  },
31
33
  required: ['Type', 'Value']
32
- },
33
- <% }) %>
34
+ }<%- index < startConfig.messageAttributes.length - 1 ? ',' : '' %>
35
+ <%_ }) _%>
34
36
  },
35
37
  required: [<%- startConfig.messageAttributes.filter(p => p.required === true).map(p => `'${p.propertyName}'`).join(', ') %>]
38
+ //(<messageAttributeValidatorSchema>)
39
+ //(</messageAttributeValidatorSchema>)
36
40
  };
37
41
  <% } else { -%>
38
42
  let messageAttributeValidatorSchema = null;
@@ -64,7 +64,7 @@ import { consts as coreConsts } from '@izara_project/izara-core-library-core';
64
64
  export default async function <%- functionName %>(
65
65
  _izContext,
66
66
  requestParams,
67
- callingFlowConfig = {},
67
+ callingFlowConfig = {}
68
68
  //(<additionalParams>)
69
69
  //(</additionalParams>)
70
70
  ) {
@@ -61,7 +61,7 @@ const { PREFIX, TOPIC_NAME_GENERATE_CODE, TOPIC_NAME_GRAPH_HANDLER } = consts;
61
61
  export default async function createRelationship(
62
62
  _izContext,
63
63
  requestParams,
64
- callingFlowConfig = {},
64
+ callingFlowConfig = {}
65
65
  //(<additionalParams>)
66
66
  //(</additionalParams>)
67
67
  ) {
@@ -61,7 +61,7 @@ const { PREFIX, TOPIC_NAME_GENERATE_CODE, TOPIC_NAME_GRAPH_HANDLER } = consts;
61
61
  export default async function deleteRelationship(
62
62
  _izContext,
63
63
  requestParams,
64
- callingFlowConfig = {},
64
+ callingFlowConfig = {}
65
65
  //(<additionalParams>)
66
66
  //(</additionalParams>)
67
67
  ) {
@@ -16,18 +16,15 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
16
16
  */
17
17
 
18
18
  import { objectHash as hash } from '@izara_project/izara-shared-core';
19
-
20
19
  import callingFlowSharedLib from '@izara_project/izara-core-library-calling-flow';
21
20
  import lambdaSharedLib from '@izara_project/izara-core-library-lambda';
22
21
  import snsSharedLib from '@izara_project/izara-core-library-sns';
23
22
  import asyncFlowSharedLib from '@izara_project/izara-core-library-asynchronous-flow';
24
23
  import dynamodbSharedLib from '@izara_project/izara-core-library-dynamodb';
25
-
26
24
  import {
27
25
  sns,
28
26
  lambda
29
27
  } from '@izara_project/izara-core-library-external-request';
30
-
31
28
  import {
32
29
  getObjectSchema,
33
30
  utils,
@@ -36,19 +33,15 @@ import {
36
33
  relSchemaLib,
37
34
  identifiersObject
38
35
  } from '@izara_project/izara-core-library-service-schemas';
39
- const { findLinksByObjTypes } = relSchemaLib;
36
+ import { consts as coreConsts } from '@izara_project/izara-core-library-core';
40
37
 
38
+ const { findLinksByObjTypes } = relSchemaLib;
41
39
  const { getRelationshipSchemaWithCache, getObjSchemaS3WithHierarchy } =
42
40
  getObjectSchema;
43
-
44
41
  const { createLinkTypeId } = utils;
45
-
46
42
  const { getGraphServiceTagWithCache } = serviceConfig;
47
-
48
43
  const { PREFIX, TOPIC_NAME_GENERATE_CODE, TOPIC_NAME_GRAPH_HANDLER } = consts;
49
44
 
50
- import { consts as coreConsts } from '@izara_project/izara-core-library-core';
51
-
52
45
  //(<optionalRequire>)
53
46
  //(</optionalRequire>)
54
47
 
@@ -66,7 +59,7 @@ import { consts as coreConsts } from '@izara_project/izara-core-library-core';
66
59
  export default async function getRelationship(
67
60
  _izContext,
68
61
  requestParams,
69
- callingFlowConfig = {},
62
+ callingFlowConfig = {}
70
63
  //(<additionalParams>)
71
64
  //(</additionalParams>)
72
65
  ) {
@@ -94,14 +87,16 @@ export default async function getRelationship(
94
87
  let errorsFound = [];
95
88
 
96
89
  //(<beforeValidateGetRel>)
97
- //(</beforeValidateGetRel>).
90
+ //(</beforeValidateGetRel>)
98
91
  // validate object and identifiers
99
92
  async function validateIdentifiersExists(
100
93
  _izContext,
101
94
  objType,
102
95
  identifiersObject
103
96
  ) {
104
- const objTypeString = `objType:{ serviceTag:${objType.serviceTag}, objectType:${objType.objectType} }`;
97
+ const objTypeString =
98
+ `objType:{ serviceTag:${objType.serviceTag}, ` +
99
+ `objectType:${objType.objectType} }`;
105
100
  const objectSchema = await getObjSchemaS3WithHierarchy(
106
101
  _izContext,
107
102
  objType
@@ -120,7 +115,8 @@ export default async function getRelationship(
120
115
  for (const identifierName of identifierNames) {
121
116
  if (!identifiersObject.hasOwnProperty(identifierName)) {
122
117
  errorsFound.push(
123
- `validateIdentifiers, ${objTypeString} property:${identifierName} not exists`
118
+ `validateIdentifiers, ${objTypeString} ` +
119
+ `property:${identifierName} not exists`
124
120
  );
125
121
  } else {
126
122
  if (
@@ -128,7 +124,8 @@ export default async function getRelationship(
128
124
  typeof identifiersObject[identifierName] !== 'number'
129
125
  ) {
130
126
  errorsFound.push(
131
- `validateIdentifiers, ${objTypeString} property:${identifierName} should be string or number`
127
+ `validateIdentifiers, ${objTypeString} ` +
128
+ `property:${identifierName} should be string or number`
132
129
  );
133
130
  }
134
131
  }
@@ -136,16 +133,21 @@ export default async function getRelationship(
136
133
  }
137
134
  }
138
135
 
139
- await validateIdentifiersExists(
140
- _izContext,
141
- firstObject.objType,
142
- firstObject.identifiers
143
- );
144
- await validateIdentifiersExists(
145
- _izContext,
146
- secondObject.objType,
147
- secondObject.identifiers
148
- );
136
+ if (firstObject && Object.values(firstObject).length > 0) {
137
+ await validateIdentifiersExists(
138
+ _izContext,
139
+ firstObject.objType,
140
+ firstObject.identifiers
141
+ );
142
+ }
143
+
144
+ if (secondObject && Object.values(secondObject).length > 0) {
145
+ await validateIdentifiersExists(
146
+ _izContext,
147
+ secondObject.objType,
148
+ secondObject.identifiers
149
+ );
150
+ }
149
151
  // finished validate object and identifiers
150
152
 
151
153
  //(<afterValidateGetRel>)
@@ -167,8 +169,14 @@ export default async function getRelationship(
167
169
  );
168
170
  _izContext.logger.debug('links', links);
169
171
  if (!links.length) {
172
+ const firstTypeStr = JSON.stringify({
173
+ firstObject: firstObject.objType
174
+ });
175
+ const secondTypeStr = JSON.stringify({
176
+ secondObject: secondObject.objType
177
+ });
170
178
  errorsFound.push(
171
- `not found link between ${JSON.stringify({ firstObject: firstObject.objType })} ${JSON.stringify({ secondObject: secondObject.objType })}`
179
+ `not found link between ${firstTypeStr} ${secondTypeStr}`
172
180
  );
173
181
  }
174
182
 
@@ -192,7 +200,7 @@ export default async function getRelationship(
192
200
  );
193
201
  }
194
202
 
195
- if (firstObjectHie || firstObject || secondObjectHie || secondObject) {
203
+ if (firstObjectHie || (firstObject && secondObjectHie) || secondObject) {
196
204
  // find targetStorageResources and validate each storageResources
197
205
  await Promise.all(
198
206
  relationshipSchema.links.map(
@@ -238,7 +246,9 @@ export default async function getRelationship(
238
246
  );
239
247
  if (!graphServiceTag) {
240
248
  errorsFound.push(
241
- `storageResourceTag: ${storageResourceTag} invalid, not found graph serviceTag from graphServerTag: ${usedStorageResource.graphServerTag}`
249
+ `storageResourceTag: ${storageResourceTag} ` +
250
+ `invalid, not found graph serviceTag from ` +
251
+ `graphServerTag: ${usedStorageResource.graphServerTag}`
242
252
  );
243
253
  }
244
254
 
@@ -322,8 +332,10 @@ export default async function getRelationship(
322
332
  return getRelCompleteMsg;
323
333
  }
324
334
 
325
- let usedGraphServiceTag = []; // collect used graph serviceTag, use to check duplicate graph serviceTag across graph serverTag
326
- let targetGraphStorageResources = []; // collect used graph storageResources, filtered duplicate graphServiceTag from graphServerTag out
335
+ // collect used graph serviceTag, use to check duplicate graph serviceTag across graph serverTag
336
+ let usedGraphServiceTag = [];
337
+ // collect used graph storageResources, filtered duplicate graphServiceTag from graphServerTag out
338
+ let targetGraphStorageResources = [];
327
339
 
328
340
  for (const targetStorageResource of targetStorageResources) {
329
341
  if (
@@ -351,7 +363,12 @@ export default async function getRelationship(
351
363
  storageResource.storageType === consts.STORAGE_TYPES.dynamoDB
352
364
  ) {
353
365
  // if have storageResource.storageType === "dynamoDB" will create relationship here
354
- let tableNameFrom = `${firstObject.objType.serviceTag}_${firstObject.objType.objectType}__${relType.relationshipTag}__${secondObject.objType.serviceTag}_${secondObject.objType.objectType}`;
366
+ let tableNameFrom =
367
+ `${firstObject.objType.serviceTag}_` +
368
+ `${firstObject.objType.objectType}__` +
369
+ `${relType.relationshipTag}__` +
370
+ `${secondObject.objType.serviceTag}_` +
371
+ `${secondObject.objType.objectType}`;
355
372
 
356
373
  let identifiersConcatFirstObject =
357
374
  await identifiersObject.identifiersConcatFromIdentifiers(
@@ -365,8 +382,12 @@ export default async function getRelationship(
365
382
  secondObject.objType,
366
383
  secondObject.identifiers
367
384
  );
368
- const firstObjectIdentifiersConcat = `${firstObject.objType.serviceTag}_${firstObject.objType.objectType}__identifiersConcat`;
369
- const secondObjectIdentifiersConcat = `${secondObject.objType.serviceTag}_${secondObject.objType.objectType}__identifiersConcat`;
385
+ const firstObjectIdentifiersConcat =
386
+ `${firstObject.objType.serviceTag}_` +
387
+ `${firstObject.objType.objectType}__identifiersConcat`;
388
+ const secondObjectIdentifiersConcat =
389
+ `${secondObject.objType.serviceTag}_` +
390
+ `${secondObject.objType.objectType}__identifiersConcat`;
370
391
  // putItem first Object DynamoDb
371
392
  let getResultFromDynamo = await dynamodbSharedLib.getItem(
372
393
  _izContext,
@@ -69,7 +69,7 @@ import { consts as coreConsts } from '@izara_project/izara-core-library-core';
69
69
  export default async function moveRelationship(
70
70
  _izContext,
71
71
  requestParams,
72
- callingFlowConfig = {},
72
+ callingFlowConfig = {}
73
73
  //(<additionalParams>)
74
74
  //(</additionalParams>)
75
75
  ) {
@@ -62,7 +62,7 @@ const { PREFIX, TOPIC_NAME_GENERATE_CODE, TOPIC_NAME_GRAPH_HANDLER } = consts;
62
62
  export default async function updateRelationship(
63
63
  _izContext,
64
64
  requestParams,
65
- callingFlowConfig = {},
65
+ callingFlowConfig = {}
66
66
  //(<additionalParams>)
67
67
  //(</additionalParams>)
68
68
  ) {
@@ -112,10 +112,6 @@ export async function emitResourceArtifacts({
112
112
  {
113
113
  path: `${APP_ROOT}/role-name-config.yml`,
114
114
  content: normalizeYaml(iam.roleNameConfigContent)
115
- },
116
- {
117
- path: `${INITIAL_SETUP_ROOT}/generatedLambdaRoleServiceConfig.js`,
118
- content: lambdaRoleConfig
119
115
  }
120
116
  ];
121
117
  if (state.s3Buckets.length > 0) {
@@ -140,7 +136,6 @@ export const resourceArtifactPaths = [
140
136
  `${RESOURCE_ROOT}/generated-s3.yml`,
141
137
  `${APP_ROOT}/generate-shared-resource.yml`,
142
138
  `${APP_ROOT}/role-name-config.yml`,
143
- `${INITIAL_SETUP_ROOT}/generatedLambdaRoleServiceConfig.js`,
144
139
  `${APP_ROOT}/cors.yml`
145
140
  ];
146
141
 
@@ -342,18 +337,35 @@ function createResourceState({ objects, relationships, flows }) {
342
337
  .map((object) => [
343
338
  object.objectType,
344
339
  Object.values(object.storageResources ?? {}).find(
345
- (resource) => resource?.storageType === 'dynamoDB'
340
+ (resource) =>
341
+ resource?.storageType === 'dynamo' ||
342
+ resource?.storageType === 'dynamoDB' ||
343
+ !resource?.storageType
346
344
  )?.tableName
347
345
  ])
348
346
  .filter(([, tableName]) => tableName)
349
347
  ),
350
348
  s3Buckets,
351
- flows
349
+ flows,
350
+ objects
352
351
  };
353
352
  }
354
353
 
354
+ function indentYaml(content, spaces = 2) {
355
+ const prefix = ' '.repeat(spaces);
356
+ return content
357
+ .split('\n')
358
+ .map((line) => {
359
+ if (line.trim()) {
360
+ return `${prefix}${line}`;
361
+ }
362
+ return '';
363
+ })
364
+ .join('\n');
365
+ }
366
+
355
367
  async function renderS3(state) {
356
- if (state.s3Buckets.length === 0) return 'Resources:';
368
+ if (state.s3Buckets.length === 0) return 'Resources:\n';
357
369
  const template = await readFile(
358
370
  new URL('S3Bucket_Yaml.ejs', TEMPLATE_URL),
359
371
  'utf8'
@@ -361,7 +373,7 @@ async function renderS3(state) {
361
373
  const chunks = await Promise.all(
362
374
  state.s3Buckets.map((bucketName) => ejsLib.render(template, { bucketName }))
363
375
  );
364
- return `Resources:\n${chunks.join('\n')}`;
376
+ return `Resources:\n${indentYaml(chunks.join('\n'), 2)}`;
365
377
  }
366
378
 
367
379
  async function renderInSqs(state) {
@@ -411,11 +423,17 @@ async function renderInSqs(state) {
411
423
  if (s3Subscriptions.length > 0) {
412
424
  parts.push(s3Subscriptions.join('\n'));
413
425
  }
414
- return `Resources:\n${parts.join('\n')}`;
426
+ const body = parts.join('\n');
427
+ return `Resources:\n${indentYaml(body, 2)}`;
415
428
  }
416
429
 
417
430
  async function renderOut(state) {
418
- return `Resources:\n${(await Promise.all(state.outTopics.map((topicName) => render('FlowOut_Yaml.ejs', { topicName })))).join('\n')}`;
431
+ const body = (
432
+ await Promise.all(
433
+ state.outTopics.map((topicName) => render('FlowOut_Yaml.ejs', { topicName }))
434
+ )
435
+ ).join('\n');
436
+ return `Resources:\n${indentYaml(body, 2)}`;
419
437
  }
420
438
 
421
439
  async function renderDynamo(state) {
@@ -423,7 +441,8 @@ async function renderDynamo(state) {
423
441
  render('SystemDynamoDB_Yaml.ejs', { hasS3: state.s3FlowTags.length > 0 }),
424
442
  ...state.tables.map((table) => render('DynamoDBTable_Yaml.ejs', table))
425
443
  ]);
426
- return `${system}\n${tables.join('\n')}`;
444
+ const indentedTables = tables.map((t) => indentYaml(t, 2)).join('\n');
445
+ return indentedTables ? `${system}\n${indentedTables}` : `${system}`;
427
446
  }
428
447
 
429
448
  async function renderIam(state) {
@@ -586,10 +605,13 @@ function roleQueueNames(state, roleName) {
586
605
  ];
587
606
  }
588
607
  if (roleName === 'FlowRbacRole') {
589
- return RBAC_ACTIONS.flatMap((action) => [
590
- `${action}HdrSqs`,
591
- `Process${action}HdrSqs`
592
- ]);
608
+ return [
609
+ ...RBAC_ACTIONS.flatMap((action) => [
610
+ `${action}HdrSqs`,
611
+ `Process${action}HdrSqs`
612
+ ]),
613
+ ...rbacFlowQueueNames(state)
614
+ ];
593
615
  }
594
616
  const flow = state.flows.find(
595
617
  (candidate) => customFlowRoleName(candidate?.flowTag ?? '') === roleName
@@ -741,7 +763,9 @@ function collectTables(schemas) {
741
763
  );
742
764
  for (const resource of Object.values(schema.storageResources)) {
743
765
  if (
744
- resource?.storageType === 'dynamoDB' &&
766
+ (resource?.storageType === 'dynamo' ||
767
+ resource?.storageType === 'dynamoDB' ||
768
+ !resource?.storageType) &&
745
769
  resource.tableName &&
746
770
  !tables.has(resource.tableName)
747
771
  )
@@ -774,6 +798,23 @@ function hasRbacAddOn(object) {
774
798
  object.addOnDataStructure.some((addOn) => addOn?.type === 'rbac')
775
799
  );
776
800
  }
801
+
802
+ /**
803
+ * Returns the per-object RBAC flow queues (e.g. UserRbacFlowHdrSqs)
804
+ * created for objects with an 'rbac' add-on. These are consumed by the
805
+ * UserRbacFlow SQS functions emitted in emitRbacApplicationArtifacts.
806
+ */
807
+ function rbacFlowQueueNames(state) {
808
+ return (state.objects ?? [])
809
+ .filter(hasRbacAddOn)
810
+ .map((object) => {
811
+ const objectType = object?.objectType;
812
+ if (typeof objectType !== 'string' || objectType.trim() === '') return null;
813
+ const flowTag = `${objectType[0].toUpperCase()}${objectType.slice(1)}RbacFlow`;
814
+ return `${flowTag}HdrSqs`;
815
+ })
816
+ .filter(Boolean);
817
+ }
777
818
  function includesEvent(flow, event) {
778
819
  return Array.isArray(flow?.event) && flow.event.includes(event);
779
820
  }
@@ -1,20 +1,20 @@
1
1
  ##===== [DynamoDB Table: <%- tableName %>]
2
- <%- tableName %>Table:
3
- Type: AWS::DynamoDB::Table
4
- Properties:
5
- TableName: ${self:custom.iz_resourcePrefix}<%- tableName %>
6
- BillingMode: PAY_PER_REQUEST
7
- AttributeDefinitions:
8
- - AttributeName: "<%- pk %>"
9
- AttributeType: "S"
10
- <% if (sk) { %>
11
- - AttributeName: "<%- sk %>"
12
- AttributeType: "S"
13
- <% } %>
14
- KeySchema:
15
- - AttributeName: "<%- pk %>"
16
- KeyType: "HASH"
17
- <% if (sk) { %>
18
- - AttributeName: "<%- sk %>"
19
- KeyType: "RANGE"
2
+ <%- tableName %>Table:
3
+ Type: AWS::DynamoDB::Table
4
+ Properties:
5
+ TableName: ${self:custom.iz_resourcePrefix}<%- tableName %>
6
+ BillingMode: PAY_PER_REQUEST
7
+ AttributeDefinitions:
8
+ - AttributeName: '<%- pk %>'
9
+ AttributeType: 'S'
10
+ <% if (sk) { %>
11
+ - AttributeName: '<%- sk %>'
12
+ AttributeType: 'S'
13
+ <% } %>
14
+ KeySchema:
15
+ - AttributeName: '<%- pk %>'
16
+ KeyType: 'HASH'
17
+ <% if (sk) { %>
18
+ - AttributeName: '<%- sk %>'
19
+ KeyType: 'RANGE'
20
20
  <% } %>
@@ -1,6 +1,6 @@
1
1
  ##===== [Topic Out]
2
- Out<%- topicName %>:
3
- Type: AWS::SNS::Topic
4
- Properties:
5
- DisplayName: "SNS Message out"
6
- TopicName: ${self:custom.iz_serviceTag}_${self:custom.iz_stage}_<%- topicName %>_Out
2
+ Out<%- topicName %>:
3
+ Type: AWS::SNS::Topic
4
+ Properties:
5
+ DisplayName: 'SNS Message out'
6
+ TopicName: ${self:custom.iz_serviceTag}_${self:custom.iz_stage}_<%- topicName %>_Out