@izara_project/izara-core-generate-service-code 1.0.67 → 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.
- package/.prettierrc +11 -0
- package/package.json +16 -12
- package/scripts/format-ejs.js +105 -0
- package/src/compile/compileProject.js +16 -1
- package/src/compile/loadSchemas.js +89 -4
- package/src/emit/crud/emitDynamicCrudFlowSchemas.js +1 -2
- package/src/emit/crud/templates/CreateEndpoint_Main.ejs +296 -105
- package/src/emit/crud/templates/DeleteEndpoint_Main.ejs +222 -144
- package/src/emit/crud/templates/FlowEndpointBeforeLogical_Main.ejs +22 -6
- package/src/emit/crud/templates/FlowEndpointComplete_Main.ejs +134 -43
- package/src/emit/crud/templates/FlowEndpoint_HdrWbs.ejs +51 -31
- package/src/emit/crud/templates/FlowHandler_HdrApi.ejs +53 -45
- package/src/emit/crud/templates/FlowHandler_HdrInv.ejs +28 -26
- package/src/emit/crud/templates/FlowHandler_HdrSqs.ejs +15 -11
- package/src/emit/crud/templates/FlowMain_Wbs.ejs +53 -38
- package/src/emit/crud/templates/GetEndpoint_Main.ejs +5 -2
- package/src/emit/crud/templates/GetRangeEndpoint_Main.ejs +2 -2
- package/src/emit/crud/templates/UpdateEndpoint_Main.ejs +402 -249
- package/src/emit/custom/customFlows.js +51 -21
- package/src/emit/custom/emitCustomFlowApplicationArtifacts.js +13 -18
- package/src/emit/custom/templates/FlowEndpoint_Main.ejs +48 -36
- package/src/emit/custom/templates/FlowStep_Main.ejs +7 -9
- package/src/emit/custom/templates/s3/ConfirmReserved_HdrSqs.ejs +59 -54
- package/src/emit/custom/templates/s3/ConfirmReserved_Main.ejs +33 -23
- package/src/emit/custom/templates/s3/CreateObject_HdrWbs.ejs +30 -23
- package/src/emit/custom/templates/s3/CreateObject_Main.ejs +56 -39
- package/src/emit/custom/templates/s3/CreatePreSignUrl_HdrSqs.ejs +56 -51
- package/src/emit/custom/templates/s3/CreatePreSignUrl_Main.ejs +112 -75
- package/src/emit/custom/templates/s3/FlowHandler_HdrS3.ejs +12 -7
- package/src/emit/custom/templates/s3/ProcessS3File_Main.ejs +11 -8
- package/src/emit/custom/templates/s3/ReservedLimit_HdrSqs.ejs +64 -55
- package/src/emit/custom/templates/s3/ReservedLimit_Main.ejs +74 -52
- package/src/emit/custom/templates/triggerCache/CheckTriggerCache_HdrSqs.ejs +58 -14
- package/src/emit/custom/templates/triggerCache/CheckTriggerCache_Main.ejs +12 -17
- package/src/emit/custom/templates/triggerCache/TriggerCacheComplete_Main.ejs +20 -13
- package/src/emit/custom/templates/triggerCache/TriggerCache_Main.ejs +4 -1
- package/src/emit/function/functionYamlArtifact.js +20 -0
- package/src/emit/rbac/emitDynamicRbacFlowSchemas.js +28 -15
- package/src/emit/rbac/emitRbacApplicationArtifacts.js +168 -69
- package/src/emit/rbac/templates/CreateTargetRole_HdrSqs.ejs +41 -18
- package/src/emit/rbac/templates/CreateTargetRole_Main.ejs +23 -3
- package/src/emit/rbac/templates/ListRbac_HdrApi.ejs +27 -5
- package/src/emit/rbac/templates/ListRbac_HdrSqs.ejs +41 -8
- package/src/emit/rbac/templates/ListRbac_Main.ejs +26 -6
- package/src/emit/rbac/templates/RbacMutation_Main.ejs +23 -3
- package/src/emit/rbac/templates/UserRbacFlow_HdrSqs.ejs +46 -0
- package/src/emit/rbac/templates/UserRbacFlow_Main.ejs +152 -33
- package/src/emit/rbac/templates/UserRoleMutation_Main.ejs +24 -4
- package/src/emit/relationship/emitDynamicRelationshipFlowSchemas.js +1 -2
- package/src/emit/relationship/templates/ChangeRelationshipComplete_Main.ejs +64 -37
- package/src/emit/relationship/templates/ChangeRelationship_Main.ejs +258 -142
- package/src/emit/relationship/templates/CreateRelationshipComplete_Main.ejs +68 -43
- package/src/emit/relationship/templates/CreateRelationship_Main.ejs +315 -171
- package/src/emit/relationship/templates/DeleteRelationshipComplete_Main.ejs +67 -41
- package/src/emit/relationship/templates/DeleteRelationship_Main.ejs +226 -115
- package/src/emit/relationship/templates/FlowHandler_HdrApi.ejs +41 -33
- package/src/emit/relationship/templates/FlowHandler_HdrDsq.ejs +15 -11
- package/src/emit/relationship/templates/FlowHandler_HdrInv.ejs +28 -26
- package/src/emit/relationship/templates/FlowHandler_HdrSqs.ejs +15 -11
- package/src/emit/relationship/templates/GetRelationshipComplete_Main.ejs +46 -26
- package/src/emit/relationship/templates/GetRelationship_Main.ejs +233 -126
- package/src/emit/relationship/templates/MoveRelationshipComplete_Main.ejs +72 -44
- package/src/emit/relationship/templates/MoveRelationship_Main.ejs +266 -150
- package/src/emit/relationship/templates/UpdateRelationshipComplete_Main.ejs +74 -45
- package/src/emit/relationship/templates/UpdateRelationship_Main.ejs +285 -152
- package/src/emit/resource/emitResourceArtifacts.js +107 -11
- package/src/emit/resource/templates/DynamoDBTable_Yaml.ejs +18 -18
- package/src/emit/resource/templates/FlowOut_Yaml.ejs +5 -5
- package/src/emit/resource/templates/GeneratedLambdaRoleServiceConfig.ejs +138 -0
- package/src/emit/resource/templates/ResourceBeforeLogicalYaml.ejs +44 -44
- package/src/emit/resource/templates/ResourceSqsYaml.ejs +36 -36
- package/src/emit/resource/templates/ResourceYaml.ejs +48 -48
- package/src/emit/resource/templates/S3Bucket_Yaml.ejs +19 -0
- package/src/emit/resource/templates/SharedResource_Yaml.ejs +11 -11
- package/src/emit/resource/templates/SystemDynamoDB_Yaml.ejs +105 -105
- package/src/generate.js +6 -2
- package/test/createTargetRoleHandler.test.js +63 -14
- package/test/customFlowApplicationArtifacts.test.js +48 -23
- package/test/dynamicCrudFlowSchemas.test.js +6 -6
- package/test/dynamicRbacFlowSchemas.test.js +8 -12
- package/test/dynamicRelationshipFlowSchemas.test.js +3 -3
- package/test/publicApi.test.js +10 -12
- package/test/resourceArtifacts.test.js +12 -2
- package/docs/test.png +0 -0
- package/src/emit/rbac/templates/UserRbacFlow_HdrInv.ejs +0 -10
- /package/docs/{test.mmd → TriggeredCacheFlow.mmd} +0 -0
|
@@ -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
|
|
24
|
-
import {
|
|
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 {
|
|
30
|
-
|
|
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(
|
|
79
|
-
|
|
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(
|
|
89
|
+
_izContext.logger.debug('res::', res);
|
|
84
90
|
|
|
85
91
|
if (res.passStatus === false) {
|
|
86
|
-
postToConnection({ message:
|
|
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(
|
|
94
|
-
|
|
99
|
+
await dynamodbSharedLib.deleteItem(
|
|
100
|
+
_izContext,
|
|
101
|
+
await dynamodbSharedLib.tableName(_izContext, 'WebSocketTask'),
|
|
95
102
|
{
|
|
96
|
-
taskKey: `${createFlowTypeConcat(_izContext, { flowTag:
|
|
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(
|
|
124
|
+
_izContext.logger.debug('callingFlowProperties', callingFlowProperties);
|
|
118
125
|
|
|
119
126
|
if (callingFlowConfig) {
|
|
120
|
-
sendMsgReservedDynamic =
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
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
|
-
//(<
|
|
126
|
-
await lambdaSharedLib.lambdaFunctionName(
|
|
127
|
-
|
|
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(
|
|
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:
|
|
174
|
+
TopicArn: snsSharedLib.snsTopicArnByFlowSchema(
|
|
175
|
+
_izContext,
|
|
176
|
+
'ReservedDynamicUsage_In',
|
|
177
|
+
schemaConsts.EXTERNAL_SERVICE_NAME.accountLimits
|
|
178
|
+
)
|
|
160
179
|
};
|
|
161
|
-
_izContext.logger.debug(
|
|
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
|
|
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(
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
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
|
-
|
|
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
|
-
{
|
|
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(
|
|
10
|
+
_izContext.logger.debug(
|
|
11
|
+
'<%- functionName %> callingFlowConfig',
|
|
12
|
+
callingFlowConfig
|
|
13
|
+
);
|
|
11
14
|
|
|
12
15
|
//(<beforeCheckTriggeredCache>)
|
|
13
16
|
//(</beforeCheckTriggeredCache>)
|
|
14
17
|
|
|
15
|
-
const checkTriggerResetedV2 =
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
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(
|
|
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(
|
|
8
|
+
_izContext.logger.debug(
|
|
9
|
+
'<%- functionName %> callingFlowConfig',
|
|
10
|
+
callingFlowConfig
|
|
11
|
+
);
|
|
9
12
|
|
|
10
13
|
//(<endpointHook>)
|
|
11
14
|
//(</endpointHook>)
|
|
@@ -72,6 +72,26 @@ ${environmentSetting(functionName, flowTag, flowStepName)}${functionSetting(func
|
|
|
72
72
|
`;
|
|
73
73
|
}
|
|
74
74
|
|
|
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
|
+
|
|
75
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');
|
|
@@ -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
|
|
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(
|
|
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 }) =>
|
|
47
|
-
flowTag,
|
|
48
|
-
|
|
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(
|
|
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
|
|
59
|
-
|
|
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(
|
|
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: ['
|
|
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' }
|