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

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 (90) hide show
  1. package/.prettierrc +11 -0
  2. package/docs/TriggeredCache Flow.drawio +193 -0
  3. package/docs/TriggeredCacheFlow.mmd +47 -0
  4. package/package.json +16 -12
  5. package/scripts/format-ejs.js +105 -0
  6. package/src/compile/compileProject.js +16 -1
  7. package/src/compile/loadSchemas.js +108 -1
  8. package/src/emit/crud/emitCrudApplicationArtifacts.js +9 -5
  9. package/src/emit/crud/emitDynamicCrudFlowSchemas.js +1 -2
  10. package/src/emit/crud/templates/CreateEndpoint_Main.ejs +300 -109
  11. package/src/emit/crud/templates/DeleteEndpoint_Main.ejs +221 -143
  12. package/src/emit/crud/templates/FlowEndpointBeforeLogical_Main.ejs +22 -6
  13. package/src/emit/crud/templates/FlowEndpointComplete_Main.ejs +150 -38
  14. package/src/emit/crud/templates/FlowEndpoint_HdrWbs.ejs +51 -31
  15. package/src/emit/crud/templates/FlowHandler_HdrApi.ejs +57 -31
  16. package/src/emit/crud/templates/FlowHandler_HdrInv.ejs +28 -26
  17. package/src/emit/crud/templates/FlowHandler_HdrSqs.ejs +15 -11
  18. package/src/emit/crud/templates/FlowMain_Wbs.ejs +53 -38
  19. package/src/emit/crud/templates/GetEndpoint_Main.ejs +6 -3
  20. package/src/emit/crud/templates/GetRangeEndpoint_Main.ejs +2 -2
  21. package/src/emit/crud/templates/UpdateEndpoint_Main.ejs +407 -252
  22. package/src/emit/custom/customFlows.js +112 -31
  23. package/src/emit/custom/emitCustomFlowApplicationArtifacts.js +89 -77
  24. package/src/emit/custom/templates/FlowEndpoint_Main.ejs +49 -37
  25. package/src/emit/custom/templates/FlowStep_Main.ejs +7 -9
  26. package/src/emit/custom/templates/s3/ConfirmReserved_HdrSqs.ejs +59 -54
  27. package/src/emit/custom/templates/s3/ConfirmReserved_Main.ejs +33 -23
  28. package/src/emit/custom/templates/s3/CreateObject_HdrWbs.ejs +30 -23
  29. package/src/emit/custom/templates/s3/CreateObject_Main.ejs +56 -39
  30. package/src/emit/custom/templates/s3/CreatePreSignUrl_HdrSqs.ejs +56 -51
  31. package/src/emit/custom/templates/s3/CreatePreSignUrl_Main.ejs +112 -75
  32. package/src/emit/custom/templates/s3/FlowHandler_HdrS3.ejs +12 -7
  33. package/src/emit/custom/templates/s3/ProcessS3File_Main.ejs +11 -8
  34. package/src/emit/custom/templates/s3/ReservedLimit_HdrSqs.ejs +64 -55
  35. package/src/emit/custom/templates/s3/ReservedLimit_Main.ejs +74 -52
  36. package/src/emit/custom/templates/triggerCache/CheckTriggerCache_HdrSqs.ejs +58 -14
  37. package/src/emit/custom/templates/triggerCache/CheckTriggerCache_Main.ejs +12 -17
  38. package/src/emit/custom/templates/triggerCache/TriggerCacheComplete_Main.ejs +20 -13
  39. package/src/emit/custom/templates/triggerCache/TriggerCache_Main.ejs +4 -1
  40. package/src/emit/function/functionYamlArtifact.js +46 -12
  41. package/src/emit/rbac/emitDynamicRbacFlowSchemas.js +28 -15
  42. package/src/emit/rbac/emitRbacApplicationArtifacts.js +179 -66
  43. package/src/emit/rbac/templates/CreateTargetRole_HdrSqs.ejs +41 -18
  44. package/src/emit/rbac/templates/CreateTargetRole_Main.ejs +23 -3
  45. package/src/emit/rbac/templates/ListRbac_HdrApi.ejs +27 -5
  46. package/src/emit/rbac/templates/ListRbac_HdrSqs.ejs +41 -8
  47. package/src/emit/rbac/templates/ListRbac_Main.ejs +26 -6
  48. package/src/emit/rbac/templates/RbacMutation_Main.ejs +23 -3
  49. package/src/emit/rbac/templates/UserRbacFlow_HdrSqs.ejs +46 -0
  50. package/src/emit/rbac/templates/UserRbacFlow_Main.ejs +152 -33
  51. package/src/emit/rbac/templates/UserRoleMutation_Main.ejs +24 -4
  52. package/src/emit/relationship/emitDynamicRelationshipFlowSchemas.js +1 -2
  53. package/src/emit/relationship/emitRelationshipApplicationArtifacts.js +6 -5
  54. package/src/emit/relationship/templates/ChangeRelationshipComplete_Main.ejs +64 -37
  55. package/src/emit/relationship/templates/ChangeRelationship_Main.ejs +260 -144
  56. package/src/emit/relationship/templates/CreateRelationshipComplete_Main.ejs +68 -43
  57. package/src/emit/relationship/templates/CreateRelationship_Main.ejs +315 -171
  58. package/src/emit/relationship/templates/DeleteRelationshipComplete_Main.ejs +67 -41
  59. package/src/emit/relationship/templates/DeleteRelationship_Main.ejs +226 -115
  60. package/src/emit/relationship/templates/FlowHandler_HdrApi.ejs +41 -33
  61. package/src/emit/relationship/templates/FlowHandler_HdrDsq.ejs +15 -11
  62. package/src/emit/relationship/templates/FlowHandler_HdrInv.ejs +28 -26
  63. package/src/emit/relationship/templates/FlowHandler_HdrSqs.ejs +15 -11
  64. package/src/emit/relationship/templates/GetRelationshipComplete_Main.ejs +46 -26
  65. package/src/emit/relationship/templates/GetRelationship_Main.ejs +233 -126
  66. package/src/emit/relationship/templates/MoveRelationshipComplete_Main.ejs +72 -44
  67. package/src/emit/relationship/templates/MoveRelationship_Main.ejs +266 -150
  68. package/src/emit/relationship/templates/UpdateRelationshipComplete_Main.ejs +74 -45
  69. package/src/emit/relationship/templates/UpdateRelationship_Main.ejs +285 -152
  70. package/src/emit/resource/emitResourceArtifacts.js +499 -108
  71. package/src/emit/resource/templates/DynamoDBTable_Yaml.ejs +18 -18
  72. package/src/emit/resource/templates/FlowOut_Yaml.ejs +5 -5
  73. package/src/emit/resource/templates/GeneratedLambdaRoleServiceConfig.ejs +138 -0
  74. package/src/emit/resource/templates/ResourceBeforeLogicalYaml.ejs +44 -44
  75. package/src/emit/resource/templates/ResourceSqsYaml.ejs +36 -36
  76. package/src/emit/resource/templates/ResourceYaml.ejs +48 -48
  77. package/src/emit/resource/templates/S3Bucket_Yaml.ejs +19 -0
  78. package/src/emit/resource/templates/SharedResource_Yaml.ejs +11 -11
  79. package/src/emit/resource/templates/SystemDynamoDB_Yaml.ejs +105 -105
  80. package/src/emit/system/emitSystemWebSocketArtifacts.js +2 -1
  81. package/src/generate.js +8 -4
  82. package/test/createTargetRoleHandler.test.js +63 -14
  83. package/test/crudApplicationArtifacts.test.js +1 -1
  84. package/test/customFlowApplicationArtifacts.test.js +71 -43
  85. package/test/dynamicCrudFlowSchemas.test.js +6 -6
  86. package/test/dynamicRbacFlowSchemas.test.js +8 -12
  87. package/test/dynamicRelationshipFlowSchemas.test.js +3 -3
  88. package/test/publicApi.test.js +11 -13
  89. package/test/resourceArtifacts.test.js +13 -3
  90. package/src/emit/rbac/templates/UserRbacFlow_HdrInv.ejs +0 -10
@@ -15,19 +15,23 @@ You should have received a copy of the GNU Affero General Public License
15
15
  along with this program. If not, see <http://www.gnu.org/licenses/>.
16
16
  */
17
17
 
18
-
19
-
20
18
  import callingFlowSharedLib from '@izara_project/izara-core-library-calling-flow';
21
19
  import lambdaSharedLib from '@izara_project/izara-core-library-lambda';
22
20
  import snsSharedLib from '@izara_project/izara-core-library-sns';
23
- import asyncFlowSharedLib from "@izara_project/izara-core-library-asynchronous-flow";
24
- import { sns, webSocket } from '@izara_project/izara-core-library-external-request';
21
+ import asyncFlowSharedLib from '@izara_project/izara-core-library-asynchronous-flow';
22
+ import {
23
+ sns,
24
+ webSocket
25
+ } from '@izara_project/izara-core-library-external-request';
25
26
  import { consts as coreConsts } from '@izara_project/izara-middleware';
26
27
  import { objectHash as hash } from '@izara_project/izara-shared-core';
27
28
  import dynamodbSharedLib from '@izara_project/izara-core-library-dynamodb';
28
29
  import { processStaticLimit } from '../../../libs/source/GenerateCodeLibs.js';
29
- import { consts as schemaConsts, utils } from "@izara_project/izara-core-library-service-schemas";
30
- const { createFlowTypeConcat } = utils
30
+ import {
31
+ consts as schemaConsts,
32
+ utils
33
+ } from '@izara_project/izara-core-library-service-schemas';
34
+ const { createFlowTypeConcat } = utils;
31
35
  const { postToConnection } = webSocket;
32
36
 
33
37
  //(<optionalRequired>)
@@ -54,51 +58,54 @@ export default async function reservedLimit(
54
58
  //(</additionalProperties>)
55
59
  callingFlowConfig = {}
56
60
  ) {
57
-
58
61
  try {
59
-
60
62
  _izContext.logger.debug('----- reservedLimit event params ----- ', {
61
63
  objType,
62
64
  objInstanceFull,
63
65
  callingFlowConfig
64
66
  });
65
67
 
66
- let connectionId = _izContext.correlationIds.get(coreConsts.CONNECTION_ID)
68
+ let connectionId = _izContext.correlationIds.get(coreConsts.CONNECTION_ID);
67
69
 
68
70
  //(<beforeReserved>)
69
71
  //(</beforeReserved>)
70
72
 
71
-
72
73
  // get static
73
74
  let payloadBeforeInvokeStaticLimit = {
74
75
  //(<additionalPropertiesStaticLimit>)
75
76
  //(</additionalPropertiesStaticLimit>)
76
- }
77
+ };
77
78
 
78
- let res = await processStaticLimit(_izContext,
79
- await lambdaSharedLib.lambdaFunctionName(_izContext, "StaticLimitProcessHdrInv", schemaConsts.EXTERNAL_SERVICE_NAME.accountLimits),
79
+ let res = await processStaticLimit(
80
+ _izContext,
81
+ await lambdaSharedLib.lambdaFunctionName(
82
+ _izContext,
83
+ 'StaticLimitProcessHdrInv',
84
+ schemaConsts.EXTERNAL_SERVICE_NAME.accountLimits
85
+ ),
80
86
  payloadBeforeInvokeStaticLimit
81
- )
87
+ );
82
88
 
83
- _izContext.logger.debug("res::", res);
89
+ _izContext.logger.debug('res::', res);
84
90
 
85
91
  if (res.passStatus === false) {
86
- postToConnection({ message: "static limit over" }, connectionId)
92
+ postToConnection({ message: 'static limit over' }, connectionId);
87
93
  let identifiers = hash({
88
94
  //(<hashIdentifiers>)
89
95
  //(</hashIdentifiers>)
90
- })
96
+ });
91
97
 
92
98
  // after post message delete websocket task
93
- await dynamodbSharedLib.deleteItem(_izContext,
94
- await dynamodbSharedLib.tableName(_izContext, "WebSocketTask"),
99
+ await dynamodbSharedLib.deleteItem(
100
+ _izContext,
101
+ await dynamodbSharedLib.tableName(_izContext, 'WebSocketTask'),
95
102
  {
96
- taskKey: `${createFlowTypeConcat(_izContext, { flowTag: "<%- flowTag %>", serviceTag: process.env.iz_serviceTag })}${identifiers}`,
103
+ taskKey: `${createFlowTypeConcat(_izContext, { flowTag: '<%- flowTag %>', serviceTag: process.env.iz_serviceTag })}${identifiers}`,
97
104
  connectionId: connectionId
98
105
  }
99
- )
106
+ );
100
107
  //(<afterFailReservedStaticLimit>)
101
- return
108
+ return;
102
109
  //(</afterFailReservedStaticLimit>)
103
110
  }
104
111
 
@@ -107,42 +114,51 @@ export default async function reservedLimit(
107
114
  let sendMsgReservedDynamic = {
108
115
  //(<additionalPropertiesReservedDynamic>)
109
116
  //(</additionalPropertiesReservedDynamic>)
110
- }
117
+ };
111
118
 
112
119
  let callingFlowProperties = {
113
120
  //(<baseCallingFlowProperties>)
114
121
  //(</baseCallingFlowProperties>)
115
- }
122
+ };
116
123
 
117
- _izContext.logger.debug("callingFlowProperties", callingFlowProperties);
124
+ _izContext.logger.debug('callingFlowProperties', callingFlowProperties);
118
125
 
119
126
  if (callingFlowConfig) {
120
- sendMsgReservedDynamic = callingFlowSharedLib.addCallingFlowToSnsRequestMessageObject(
121
- sendMsgReservedDynamic,
122
- callingFlowSharedLib.addParentCallingFlowConfig(
123
- callingFlowConfig,
127
+ sendMsgReservedDynamic =
128
+ callingFlowSharedLib.addCallingFlowToSnsRequestMessageObject(
129
+ sendMsgReservedDynamic,
130
+ callingFlowSharedLib.addParentCallingFlowConfig(
131
+ callingFlowConfig,
132
+ callingFlowSharedLib.createCallingFlowConfig(
133
+ //(<callingFlowPropertiesIfHaveCallingFlowConfig>)
134
+ await lambdaSharedLib.lambdaFunctionName(
135
+ _izContext,
136
+ 'ReservedLimitCompleteHdrSqs'
137
+ ),
138
+ //(</callingFlowPropertiesIfHaveCallingFlowConfig>)
139
+ callingFlowProperties
140
+ )
141
+ )
142
+ );
143
+ } else {
144
+ sendMsgReservedDynamic =
145
+ callingFlowSharedLib.addCallingFlowToSnsRequestMessageObject(
146
+ sendMsgReservedDynamic,
124
147
  callingFlowSharedLib.createCallingFlowConfig(
125
- //(<callingFlowPropertiesIfHaveCallingFlowConfig>)
126
- await lambdaSharedLib.lambdaFunctionName(_izContext, "ReservedLimitCompleteHdrSqs"),
127
- //(</callingFlowPropertiesIfHaveCallingFlowConfig>)
148
+ //(<callingFlowPropertiesIfNotHaveCallingFlowConfig>)
149
+ await lambdaSharedLib.lambdaFunctionName(
150
+ _izContext,
151
+ 'ReservedLimitCompleteHdrSqs'
152
+ ),
153
+ //(</callingFlowPropertiesIfNotHaveCallingFlowConfig>)
128
154
  callingFlowProperties
129
155
  )
130
- )
131
- )
132
- } else {
133
- sendMsgReservedDynamic = callingFlowSharedLib.addCallingFlowToSnsRequestMessageObject(
134
- sendMsgReservedDynamic,
135
- callingFlowSharedLib.createCallingFlowConfig(
136
- //(<callingFlowPropertiesIfNotHaveCallingFlowConfig>)
137
- await lambdaSharedLib.lambdaFunctionName(_izContext, "ReservedLimitCompleteHdrSqs"),
138
- //(</callingFlowPropertiesIfNotHaveCallingFlowConfig>)
139
- callingFlowProperties
140
- )
141
- );
156
+ );
142
157
  }
143
158
 
144
159
  // create awaitingSteps
145
- await asyncFlowSharedLib.createAwaitingStep(_izContext,
160
+ await asyncFlowSharedLib.createAwaitingStep(
161
+ _izContext,
146
162
  asyncFlowSharedLib.createAwaitingStepId(
147
163
  //(<createAwaitStepId>)
148
164
  //(</createAwaitStepId>)
@@ -151,22 +167,28 @@ export default async function reservedLimit(
151
167
  //(<createPendingStepId>)
152
168
  //(</createPendingStepId>)
153
169
  )
154
- )
155
-
170
+ );
156
171
 
157
172
  let sendMessageToReservedDynamic = {
158
173
  Message: JSON.stringify(sendMsgReservedDynamic),
159
- TopicArn: await snsSharedLib.snsTopicArnByFlowSchema(_izContext, "ReservedDynamicUsage_In", schemaConsts.EXTERNAL_SERVICE_NAME.accountLimits)
174
+ TopicArn: snsSharedLib.snsTopicArnByFlowSchema(
175
+ _izContext,
176
+ 'ReservedDynamicUsage_In',
177
+ schemaConsts.EXTERNAL_SERVICE_NAME.accountLimits
178
+ )
160
179
  };
161
- _izContext.logger.debug("sendMessageToReservedDynamic", sendMessageToReservedDynamic);
180
+ _izContext.logger.debug(
181
+ 'sendMessageToReservedDynamic',
182
+ sendMessageToReservedDynamic
183
+ );
162
184
  await sns.publishAsync(_izContext, sendMessageToReservedDynamic);
163
185
 
164
186
  return {
165
187
  objType,
166
- objInstanceFull,
167
- }
188
+ objInstanceFull
189
+ };
168
190
  } catch (err) {
169
191
  _izContext.logger.error('error GetSignedUrlAccountLimit: ', err);
170
- throw (err)
192
+ throw err;
171
193
  }
172
194
  }
@@ -5,24 +5,68 @@ import callingFlowSharedLib from '@izara_project/izara-core-library-calling-flow
5
5
 
6
6
  import <%- functionName %> from './<%- functionName %>_Main.js';
7
7
 
8
+ let perRecordsValidatorSchema = {
9
+ <% if (typeof startConfig !== 'undefined' && startConfig !== null && startConfig.properties && startConfig.properties.length > 0) { -%>
10
+ type: 'object',
11
+ properties: {
12
+ <% startConfig.properties.forEach((prop, index) => { %> <%- prop.propertyName %>: {
13
+ type: '<%- prop.type || 'string' %>'
14
+ } /*__EJS_COMMA_6__*/
15
+ <% }) %>
16
+ },
17
+ required: [<%- startConfig.properties.filter(p => p.required !== false).map(p => `'${p.propertyName}'`).join(', ') %>]
18
+ <% } -%>
19
+ };
20
+
21
+ <% if (typeof startConfig !== 'undefined' && startConfig !== null && startConfig.messageAttributes && startConfig.messageAttributes.length > 0) { -%>
22
+ let messageAttributeValidatorSchema = {
23
+ type: 'object',
24
+ properties: {
25
+ <% startConfig.messageAttributes.forEach((prop, index) => { %> <%- prop.propertyName %>: {
26
+ type: 'object',
27
+ properties: {
28
+ Type: { type: 'string' },
29
+ Value: { type: '<%- prop.type || 'string' %>' }
30
+ },
31
+ required: ['Type', 'Value']
32
+ } /*__EJS_COMMA_14__*/
33
+ <% }) %>
34
+ },
35
+ required: [<%- startConfig.messageAttributes.filter(p => p.required !== false).map(p => `'${p.propertyName}'`).join(', ') %>]
36
+ };
37
+ <% } else { -%>
38
+ let messageAttributeValidatorSchema = null;
39
+ <% } -%>
40
+
8
41
  middleware.setValidatorSchema(recordHandlerSharedLib.baseValidatorSchema());
9
42
 
10
- export const main = middleware.wrap(async event => {
43
+ export const main = middleware.wrap(async (event) => {
11
44
  try {
12
45
  const recordPromises = [];
13
- await Promise.all(event.Records.map(async record => {
14
- await recordHandlerSharedLib.validateRecord(record, '<%- queueName %>', {}, null);
15
- recordPromises.push(recordHandlerSharedLib.recordHandler(
16
- record,
17
- <%- functionName %>,
18
- '<%- queueName %>',
19
- [
20
- record.body.Message.identifiers,
21
- record.body.TopicArn,
22
- callingFlowSharedLib.addCallingFlowToPassOnProperties(record.body.Message)
23
- ]
24
- ));
25
- }));
46
+ await Promise.all(
47
+ event.Records.map(async (record) => {
48
+ await recordHandlerSharedLib.validateRecord(
49
+ record,
50
+ '<%- queueName %>',
51
+ perRecordsValidatorSchema,
52
+ messageAttributeValidatorSchema
53
+ );
54
+ recordPromises.push(
55
+ recordHandlerSharedLib.recordHandler(
56
+ record,
57
+ <%- functionName %>,
58
+ '<%- queueName %>',
59
+ [
60
+ record.body.Message,
61
+ record.body.TopicArn,
62
+ callingFlowSharedLib.addCallingFlowToPassOnProperties(
63
+ record.body.Message
64
+ )
65
+ ]
66
+ )
67
+ );
68
+ })
69
+ );
26
70
  await Promise.all(recordPromises);
27
71
  return event.Records;
28
72
  } catch (error) {
@@ -1,6 +1,9 @@
1
1
  import { getObjectSchema } from '@izara_project/izara-core-library-service-schemas';
2
2
  import { triggeredCacheSharedLibV2 } from '@izara_project/izara-core-library-trigger-cache';
3
3
 
4
+ //(<optionalRequire>)
5
+ //(</optionalRequire>)
6
+
4
7
  export default async function <%- functionName %>(
5
8
  _izContext,
6
9
  requestParams,
@@ -8,14 +11,8 @@ export default async function <%- functionName %>(
8
11
  callingFlowConfig = {}
9
12
  ) {
10
13
  try {
11
- _izContext.logger.debug(
12
- '<%- functionName %> requestParams',
13
- requestParams
14
- );
15
- _izContext.logger.debug(
16
- '<%- functionName %> topicArn',
17
- topicArn
18
- );
14
+ _izContext.logger.debug('<%- functionName %> requestParams', requestParams);
15
+ _izContext.logger.debug('<%- functionName %> topicArn', topicArn);
19
16
  _izContext.logger.debug(
20
17
  '<%- functionName %> callingFlowConfig',
21
18
  callingFlowConfig
@@ -39,13 +36,14 @@ export default async function <%- functionName %>(
39
36
  _izContext,
40
37
  { serviceTag: topicName[0], flowTag: topicName[2] },
41
38
  identifiers,
42
- { flowTag: '<%- flowTag %>', serviceTag: process.env.iz_serviceTag }
39
+ {
40
+ flowTag: '<%- flowTag %>',
41
+ serviceTag: process.env.iz_serviceTag,
42
+ targetCompleteStep: process.env.iz_targetCompleteStepName
43
+ }
43
44
  );
44
45
 
45
- _izContext.logger.debug(
46
- '<%- functionName %> flowSchema',
47
- flowSchema
48
- );
46
+ _izContext.logger.debug('<%- functionName %> flowSchema', flowSchema);
49
47
  _izContext.logger.debug(
50
48
  '<%- functionName %> checkTriggerCache',
51
49
  checkTriggerCache
@@ -54,10 +52,7 @@ export default async function <%- functionName %>(
54
52
  //(<endpointHook>)
55
53
  //(</endpointHook>)
56
54
  } catch (error) {
57
- _izContext.logger.error(
58
- '<%- functionName %> failed',
59
- error
60
- );
55
+ _izContext.logger.error('<%- functionName %> failed', error);
61
56
  throw error;
62
57
  }
63
58
  }
@@ -7,24 +7,31 @@ export default async function <%- functionName %>(
7
7
  ) {
8
8
  try {
9
9
  _izContext.logger.debug('<%- functionName %> requestParams', requestParams);
10
- _izContext.logger.debug('<%- functionName %> callingFlowConfig', callingFlowConfig);
10
+ _izContext.logger.debug(
11
+ '<%- functionName %> callingFlowConfig',
12
+ callingFlowConfig
13
+ );
11
14
 
12
15
  //(<beforeCheckTriggeredCache>)
13
16
  //(</beforeCheckTriggeredCache>)
14
17
 
15
- const checkTriggerResetedV2 = await triggeredCacheSharedLibV2.checkTriggerResetedV2(
16
- _izContext,
17
- { serviceTag: process.env.iz_serviceTag, flowTag: '<%- flowTag %>' },
18
- //(<identifiers>)
19
- {},
20
- //(</identifiers>)
21
- //(<uniqueRequestId>)
22
- //(</uniqueRequestId>)
23
- //(<settings>)
24
- //(</settings>)
25
- );
18
+ const checkTriggerResetedV2 =
19
+ await triggeredCacheSharedLibV2.checkTriggerResetedV2(
20
+ _izContext,
21
+ { serviceTag: process.env.iz_serviceTag, flowTag: '<%- flowTag %>' },
22
+ //(<identifiers>)
23
+ {}
24
+ //(</identifiers>)
25
+ //(<uniqueRequestId>)
26
+ //(</uniqueRequestId>)
27
+ //(<settings>)
28
+ //(</settings>)
29
+ );
26
30
 
27
- _izContext.logger.debug('<%- functionName %> checkTriggerResetedV2', checkTriggerResetedV2);
31
+ _izContext.logger.debug(
32
+ '<%- functionName %> checkTriggerResetedV2',
33
+ checkTriggerResetedV2
34
+ );
28
35
 
29
36
  //(<endpointHook>)
30
37
  //(</endpointHook>)
@@ -5,7 +5,10 @@ export default async function <%- functionName %>(
5
5
  ) {
6
6
  try {
7
7
  _izContext.logger.debug('<%- functionName %> requestParams', requestParams);
8
- _izContext.logger.debug('<%- functionName %> callingFlowConfig', callingFlowConfig);
8
+ _izContext.logger.debug(
9
+ '<%- functionName %> callingFlowConfig',
10
+ callingFlowConfig
11
+ );
9
12
 
10
13
  //(<endpointHook>)
11
14
  //(</endpointHook>)
@@ -1,14 +1,14 @@
1
- export function createSqsFunctionYamlArtifact({ functionName, handlerPath, roleName, queueName, fileName }) {
1
+ export function createSqsFunctionYamlArtifact({ functionName, handlerPath, roleName, queueName, fileName, flowTag, flowStepName, targetCompleteStepName }) {
2
2
  if (![functionName, handlerPath, roleName, queueName, fileName].every(value => typeof value === 'string' && value !== '')) {
3
3
  throw new TypeError('Function descriptor must include functionName, handlerPath, roleName, queueName, and fileName');
4
4
  }
5
5
  return {
6
6
  path: `app/sls_yaml/generatedCode/source/${fileName}`,
7
- content: renderSqsFunctionYaml({ functionName, handlerPath, roleName, queueName })
7
+ content: renderSqsFunctionYaml({ functionName, handlerPath, roleName, queueName, flowTag, flowStepName })
8
8
  };
9
9
  }
10
10
 
11
- export function renderSqsFunctionYaml({ functionName, handlerPath, roleName, queueName }) {
11
+ export function renderSqsFunctionYaml({ functionName, handlerPath, roleName, queueName, flowTag, flowStepName, targetCompleteStepName }) {
12
12
  if (![functionName, handlerPath, roleName, queueName].every(value => typeof value === 'string' && value !== '')) {
13
13
  throw new TypeError('SQS function descriptor must include functionName, handlerPath, roleName, and queueName');
14
14
  }
@@ -16,7 +16,7 @@ export function renderSqsFunctionYaml({ functionName, handlerPath, roleName, que
16
16
  handler: ${handlerPath}
17
17
  name: \${self:custom.iz_resourcePrefix}${functionName}
18
18
  role: ${roleName}
19
- ${functionSetting(functionName)}
19
+ ${environmentSetting(functionName, flowTag, flowStepName, targetCompleteStepName)}${functionSetting(functionName)}
20
20
  events:
21
21
  - sqs:
22
22
  arn: arn:aws:sqs:\${self:custom.iz_region}:\${self:custom.iz_accountId}:\${self:custom.iz_resourcePrefix}${queueName}
@@ -24,7 +24,7 @@ ${functionSetting(functionName)}
24
24
  ${completionFilter(functionName)}`;
25
25
  }
26
26
 
27
- export function renderApiFunctionYaml({ functionName, handlerPath, roleName, routes = [] }) {
27
+ export function renderApiFunctionYaml({ functionName, handlerPath, roleName, routes = [], flowTag, flowStepName }) {
28
28
  if (!Array.isArray(routes)) {
29
29
  throw new TypeError('API function routes must be an array');
30
30
  }
@@ -41,12 +41,12 @@ export function renderApiFunctionYaml({ functionName, handlerPath, roleName, rou
41
41
  handler: ${handlerPath}
42
42
  name: \${self:custom.iz_resourcePrefix}${functionName}
43
43
  role: ${roleName}
44
- ${functionSetting(functionName)}
44
+ ${environmentSetting(functionName, flowTag, flowStepName)}${functionSetting(functionName)}
45
45
  events:
46
46
  ${routeEvents ? `${routeEvents}\n` : ''}`;
47
47
  }
48
48
 
49
- export function renderWbsFunctionYaml({ functionName, handlerPath, roleName, routeName }) {
49
+ export function renderWbsFunctionYaml({ functionName, handlerPath, roleName, routeName, flowTag, flowStepName }) {
50
50
  if (![functionName, handlerPath, roleName, routeName].every(value => typeof value === 'string' && value !== '')) {
51
51
  throw new TypeError('WebSocket function descriptor must include functionName, handlerPath, roleName, and routeName');
52
52
  }
@@ -54,7 +54,7 @@ export function renderWbsFunctionYaml({ functionName, handlerPath, roleName, rou
54
54
  handler: ${handlerPath}
55
55
  name: \${self:custom.iz_resourcePrefix}${functionName}
56
56
  role: ${roleName}
57
- ${functionSetting(functionName)}
57
+ ${environmentSetting(functionName, flowTag, flowStepName)}${functionSetting(functionName)}
58
58
  events:
59
59
  - websocket:
60
60
  route: ${routeName}
@@ -63,16 +63,36 @@ ${functionSetting(functionName)}
63
63
  `;
64
64
  }
65
65
 
66
- export function renderInvFunctionYaml({ functionName, handlerPath, roleName }) {
66
+ export function renderInvFunctionYaml({ functionName, handlerPath, roleName, flowTag, flowStepName }) {
67
67
  return `${functionName}:
68
68
  handler: ${handlerPath}
69
69
  name: \${self:custom.iz_resourcePrefix}${functionName}
70
70
  role: ${roleName}
71
- ${functionSetting(functionName)}
71
+ ${environmentSetting(functionName, flowTag, flowStepName)}${functionSetting(functionName)}
72
72
  `;
73
73
  }
74
74
 
75
- export function renderEventBridgeFunctionYaml({ functionName, handlerPath, roleName, flowTag, schedules = [] }) {
75
+ export function renderS3FunctionYaml({ functionName, handlerPath, roleName, bucketName, flowTag, flowStepName }) {
76
+ return `${functionName}:
77
+ handler: ${handlerPath}
78
+ name: \${self:custom.iz_resourcePrefix}${functionName}
79
+ role: ${roleName}
80
+ ${environmentSetting(functionName, flowTag, flowStepName)}${functionSetting(functionName)}
81
+ events:
82
+ - s3:
83
+ bucket: ${bucketName}
84
+ event: s3:ObjectCreated:*
85
+ existing: true
86
+ rules:
87
+ #<#${functionName}rules#>
88
+ #<#/${functionName}rules#>
89
+ - prefix: uploads/
90
+ - suffix: .csv
91
+ forceDeploy: true
92
+ `;
93
+ }
94
+
95
+ export function renderEventBridgeFunctionYaml({ functionName, handlerPath, roleName, flowTag, flowStepName, schedules = [] }) {
76
96
  if (![functionName, handlerPath, roleName, flowTag].every(value => typeof value === 'string' && value !== '') || !Array.isArray(schedules)) {
77
97
  throw new TypeError('EventBridge function descriptor must include functionName, handlerPath, roleName, flowTag, and schedules');
78
98
  }
@@ -85,11 +105,25 @@ export function renderEventBridgeFunctionYaml({ functionName, handlerPath, roleN
85
105
  return `\${self:custom.iz_resourcePrefix}${functionName}:
86
106
  handler: ${handlerPath}
87
107
  role: ${roleName}
88
- ${functionSetting(functionName)}
108
+ ${environmentSetting(functionName, flowTag, flowStepName)}${functionSetting(functionName)}
89
109
  description: ${flowTag} (EventBridge Schedule)
90
110
  ${schedules.length === 0 ? '' : ` events:\n${schedules.map(schedule => ` - schedule:\n name: \${self:custom.iz_resourcePrefix}${schedule.name}\n description: '${schedule.description ?? ''}'\n rate: ${schedule.rate?.[0]}\n enabled: true`).join('\n')}\n`}`;
91
111
  }
92
112
 
113
+ function environmentSetting(functionName, flowTag, flowStepName, targetCompleteStepName) {
114
+ if (flowTag === undefined && flowStepName === undefined && targetCompleteStepName === undefined) return '';
115
+ let envs = [];
116
+ if (flowTag !== undefined) envs.push(` iz_flowTag: ${flowTag === '' ? "''" : flowTag}`);
117
+ if (flowStepName !== undefined) envs.push(` iz_flowStepName: ${flowStepName === '' ? "''" : flowStepName}`);
118
+ if (targetCompleteStepName !== undefined) envs.push(` iz_targetCompleteStepName: ${flowTag}${targetCompleteStepName}`);
119
+
120
+ if (envs.length === 0) return '';
121
+ return ` environment:
122
+ ${envs.join('\n')}
123
+ #<#${functionName}Environment#>
124
+ #<#/${functionName}Environment#>\n`;
125
+ }
126
+
93
127
  function functionSetting(functionName) {
94
128
  return ` #<#${functionName}FunctionSetting#>\n #<#/${functionName}FunctionSetting#>`;
95
129
  }
@@ -16,7 +16,7 @@ const RBAC_FLOW_DEFINITIONS = [
16
16
  const TEMPLATE_URL = new URL('./templates/', import.meta.url);
17
17
 
18
18
  export const dynamicRbacFlowSchemaPaths = RBAC_FLOW_DEFINITIONS.map(
19
- ({ flowTag }) => `app/src/schemas/FlowSchemas/generateCode/${flowTag}.js`
19
+ ({ flowTag }) => `app/src/schemas/FlowSchemas/generateCode/FlowRbac/${flowTag}.js`
20
20
  );
21
21
 
22
22
  export function rbacFlowSchemaManagedPaths(objects = []) {
@@ -25,7 +25,12 @@ export function rbacFlowSchemaManagedPaths(objects = []) {
25
25
  }
26
26
  return [
27
27
  ...dynamicRbacFlowSchemaPaths,
28
- ...objects.filter(hasRbacAddOn).map(object => `app/src/schemas/FlowSchemas/generateCode/${rbacFlowTag(object)}.js`)
28
+ ...objects
29
+ .filter(hasRbacAddOn)
30
+ .map(
31
+ object =>
32
+ `app/src/schemas/FlowSchemas/generateCode/FlowRbac/${rbacFlowTag(object)}.js`
33
+ )
29
34
  ];
30
35
  }
31
36
 
@@ -39,31 +44,40 @@ export async function emitDynamicRbacFlowSchemas({ objects, serviceTag }) {
39
44
  return [];
40
45
  }
41
46
  if (typeof serviceTag !== 'string' || serviceTag.trim() === '') {
42
- throw new TypeError('GenerationRequest.serviceTag is required when generating RBAC schemas');
47
+ throw new TypeError(
48
+ 'GenerationRequest.serviceTag is required when generating RBAC schemas'
49
+ );
43
50
  }
44
51
 
45
52
  return Promise.all([
46
- ...RBAC_FLOW_DEFINITIONS.map(({ flowTag, event }) => artifact(
47
- flowTag,
48
- createSharedRbacFlow(flowTag, event)
49
- )),
53
+ ...RBAC_FLOW_DEFINITIONS.map(({ flowTag, event }) =>
54
+ artifact(flowTag, createSharedRbacFlow(flowTag, event))
55
+ ),
50
56
  ...rbacObjects.map(object => {
51
57
  const flowTag = rbacFlowTag(object);
52
- return artifact(flowTag, createUserRbacFlow(flowTag, serviceTag, object.objectType));
58
+ return artifact(
59
+ flowTag,
60
+ createUserRbacFlow(flowTag, serviceTag, object.objectType)
61
+ );
53
62
  })
54
63
  ]);
55
64
  }
56
65
 
57
66
  function hasRbacAddOn(object) {
58
- return Array.isArray(object?.addOnDataStructure)
59
- && object.addOnDataStructure.some(addOn => addOn?.type === 'rbac');
67
+ return (
68
+ Array.isArray(object?.addOnDataStructure) &&
69
+ object.addOnDataStructure.some(addOn => addOn?.type === 'rbac')
70
+ );
60
71
  }
61
72
 
62
73
  async function artifact(flowTag, flow) {
63
74
  return {
64
- path: `app/src/schemas/FlowSchemas/generateCode/${flowTag}.js`,
75
+ path: `app/src/schemas/FlowSchemas/generateCode/FlowRbac/${flowTag}.js`,
65
76
  content: ejs.render(
66
- await readFile(new URL('DynamicRbacFlowSchema.ejs', TEMPLATE_URL), 'utf8'),
77
+ await readFile(
78
+ new URL('DynamicRbacFlowSchema.ejs', TEMPLATE_URL),
79
+ 'utf8'
80
+ ),
67
81
  { flowTag, flow }
68
82
  )
69
83
  };
@@ -72,7 +86,6 @@ async function artifact(flowTag, flow) {
72
86
  function createSharedRbacFlow(flowTag, event) {
73
87
  return {
74
88
  flowTag,
75
- fileName: 'flow-rbac',
76
89
  initiateBy: 'system',
77
90
  statusType: 'none',
78
91
  event,
@@ -97,12 +110,12 @@ function createSharedRbacFlow(flowTag, event) {
97
110
  function createUserRbacFlow(flowTag, serviceTag, objectType) {
98
111
  return {
99
112
  flowTag,
100
- fileName: 'flow-rbac',
101
113
  objType: { serviceTag, objectType },
102
- event: ['lambdaSyncInv'],
114
+ event: ['ownTopic'],
103
115
  initiateBy: 'system',
104
116
  handleObj: 'one',
105
117
  statusType: 'none',
118
+ outputTopic: true,
106
119
  stepMessageAttributes: {
107
120
  userId: { propertyName: 'x-correlation-base-user-id', type: 'string' },
108
121
  correlationId: { propertyName: 'x-correlation-id', type: 'string' }