@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
|
@@ -32,20 +32,51 @@ export async function emitRbacApplicationArtifacts(objects) {
|
|
|
32
32
|
...handlers.flatMap(handler => handler.artifacts),
|
|
33
33
|
{
|
|
34
34
|
path: FLOW_RBAC_YAML_PATH,
|
|
35
|
-
content: handlers
|
|
35
|
+
content: handlers
|
|
36
|
+
.flatMap(handler => handler.functions)
|
|
37
|
+
.map(renderFunctionYaml)
|
|
38
|
+
.join('\n')
|
|
36
39
|
}
|
|
37
40
|
];
|
|
38
41
|
}
|
|
39
42
|
|
|
40
43
|
const LIST_DEFINITIONS = [
|
|
41
|
-
{
|
|
42
|
-
|
|
43
|
-
|
|
44
|
+
{
|
|
45
|
+
flowTag: 'ListTargetRole',
|
|
46
|
+
tableName: 'TargetRoles',
|
|
47
|
+
requestProperty: 'userId',
|
|
48
|
+
useContextUserId: true
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
flowTag: 'ListRolePermissions',
|
|
52
|
+
tableName: 'RolePermissions',
|
|
53
|
+
requestProperty: 'roleIdKey'
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
flowTag: 'ListUserInRoles',
|
|
57
|
+
tableName: 'RoleUsers',
|
|
58
|
+
requestProperty: 'roleIdKey'
|
|
59
|
+
}
|
|
44
60
|
];
|
|
45
61
|
const MUTATION_DEFINITIONS = [
|
|
46
|
-
{
|
|
47
|
-
|
|
48
|
-
|
|
62
|
+
{
|
|
63
|
+
flowTag: 'CreateRolePermissions',
|
|
64
|
+
tableName: 'RolePermissions',
|
|
65
|
+
method: 'putItem',
|
|
66
|
+
fields: ['roleIdKey', 'flowTypeConcat', 'parameterGroups']
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
flowTag: 'DeleteRolePermissions',
|
|
70
|
+
tableName: 'RolePermissions',
|
|
71
|
+
method: 'deleteItem',
|
|
72
|
+
fields: ['roleIdKey', 'flowTypeConcat']
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
flowTag: 'DeleteTargetRole',
|
|
76
|
+
tableName: 'TargetRoles',
|
|
77
|
+
method: 'deleteItem',
|
|
78
|
+
fields: ['targetId', 'roleIdKey']
|
|
79
|
+
}
|
|
49
80
|
];
|
|
50
81
|
const USER_ROLE_MUTATIONS = [
|
|
51
82
|
{ flowTag: 'CreateUserRole', operation: 'Put' },
|
|
@@ -57,33 +88,33 @@ export function rbacApplicationManagedPaths(objects = []) {
|
|
|
57
88
|
throw new TypeError('objects must be an array');
|
|
58
89
|
}
|
|
59
90
|
return [
|
|
60
|
-
'app/src/generatedCode/FlowRbac/CreateTargetRole/source/ProcessCreateTargetRole_Main.js',
|
|
61
|
-
'app/src/generatedCode/FlowRbac/CreateTargetRole/source/ProcessCreateTargetRole_HdrSqs.js',
|
|
62
91
|
'app/src/generatedCode/FlowRbac/CreateTargetRole/source/CreateTargetRole_Main.js',
|
|
92
|
+
'app/src/generatedCode/FlowRbac/CreateTargetRole/source/CreateTargetRole_HdrSqs.js',
|
|
93
|
+
'app/src/generatedCode/FlowRbac/CreateTargetRole/source/CreateTargetRole_WbsMain.js',
|
|
63
94
|
'app/src/generatedCode/FlowRbac/CreateTargetRole/source/CreateTargetRole_HdrWbs.js',
|
|
64
95
|
...LIST_DEFINITIONS.flatMap(({ flowTag }) => [
|
|
65
|
-
`app/src/generatedCode/FlowRbac/${flowTag}/source
|
|
66
|
-
`app/src/generatedCode/FlowRbac/${flowTag}/source
|
|
67
|
-
`app/src/generatedCode/FlowRbac/${flowTag}/source
|
|
96
|
+
`app/src/generatedCode/FlowRbac/${flowTag}/source/${flowTag}_Main.js`,
|
|
97
|
+
`app/src/generatedCode/FlowRbac/${flowTag}/source/${flowTag}_HdrSqs.js`,
|
|
98
|
+
`app/src/generatedCode/FlowRbac/${flowTag}/source/${flowTag}_HdrApi.js`
|
|
68
99
|
]),
|
|
69
100
|
...MUTATION_DEFINITIONS.flatMap(({ flowTag }) => [
|
|
70
|
-
`app/src/generatedCode/FlowRbac/${flowTag}/source/Process${flowTag}_Main.js`,
|
|
71
|
-
`app/src/generatedCode/FlowRbac/${flowTag}/source/Process${flowTag}_HdrSqs.js`,
|
|
72
101
|
`app/src/generatedCode/FlowRbac/${flowTag}/source/${flowTag}_Main.js`,
|
|
102
|
+
`app/src/generatedCode/FlowRbac/${flowTag}/source/${flowTag}_HdrSqs.js`,
|
|
103
|
+
`app/src/generatedCode/FlowRbac/${flowTag}/source/${flowTag}_WbsMain.js`,
|
|
73
104
|
`app/src/generatedCode/FlowRbac/${flowTag}/source/${flowTag}_HdrWbs.js`
|
|
74
105
|
]),
|
|
75
106
|
...USER_ROLE_MUTATIONS.flatMap(({ flowTag }) => [
|
|
76
|
-
`app/src/generatedCode/FlowRbac/${flowTag}/source/Process${flowTag}_Main.js`,
|
|
77
|
-
`app/src/generatedCode/FlowRbac/${flowTag}/source/Process${flowTag}_HdrSqs.js`,
|
|
78
107
|
`app/src/generatedCode/FlowRbac/${flowTag}/source/${flowTag}_Main.js`,
|
|
108
|
+
`app/src/generatedCode/FlowRbac/${flowTag}/source/${flowTag}_HdrSqs.js`,
|
|
109
|
+
`app/src/generatedCode/FlowRbac/${flowTag}/source/${flowTag}_WbsMain.js`,
|
|
79
110
|
`app/src/generatedCode/FlowRbac/${flowTag}/source/${flowTag}_HdrWbs.js`
|
|
80
111
|
]),
|
|
81
112
|
...objects.filter(hasRbacAddOn).flatMap(object => {
|
|
82
113
|
const flowTag = rbacFlowTag(object);
|
|
83
114
|
const sourcePath = `app/src/generatedCode/FlowRbac/${flowTag}/source`;
|
|
84
115
|
return [
|
|
85
|
-
`${sourcePath}
|
|
86
|
-
`${sourcePath}
|
|
116
|
+
`${sourcePath}/${flowTag}_Main.js`,
|
|
117
|
+
`${sourcePath}/${flowTag}_HdrSqs.js`
|
|
87
118
|
];
|
|
88
119
|
}),
|
|
89
120
|
FLOW_RBAC_YAML_PATH
|
|
@@ -91,31 +122,38 @@ export function rbacApplicationManagedPaths(objects = []) {
|
|
|
91
122
|
}
|
|
92
123
|
|
|
93
124
|
function hasRbacAddOn(object) {
|
|
94
|
-
return
|
|
95
|
-
|
|
125
|
+
return (
|
|
126
|
+
Array.isArray(object?.addOnDataStructure) &&
|
|
127
|
+
object.addOnDataStructure.some(addOn => addOn?.type === 'rbac')
|
|
128
|
+
);
|
|
96
129
|
}
|
|
97
130
|
|
|
98
131
|
async function createTargetRoleHandler() {
|
|
99
132
|
const sourcePath = 'app/src/generatedCode/FlowRbac/CreateTargetRole/source';
|
|
100
|
-
const webSocket = await createWebSocketEntry(
|
|
133
|
+
const webSocket = await createWebSocketEntry(
|
|
134
|
+
'CreateTargetRole',
|
|
135
|
+
sourcePath,
|
|
136
|
+
'src/generatedCode/FlowRbac/CreateTargetRole/source'
|
|
137
|
+
);
|
|
101
138
|
return {
|
|
102
139
|
artifacts: [
|
|
103
140
|
{
|
|
104
|
-
path: 'app/src/generatedCode/FlowRbac/CreateTargetRole/source/
|
|
141
|
+
path: 'app/src/generatedCode/FlowRbac/CreateTargetRole/source/CreateTargetRole_Main.js',
|
|
105
142
|
content: await renderRbacTemplate('CreateTargetRole_Main.ejs')
|
|
106
143
|
},
|
|
107
144
|
{
|
|
108
|
-
path: 'app/src/generatedCode/FlowRbac/CreateTargetRole/source/
|
|
145
|
+
path: 'app/src/generatedCode/FlowRbac/CreateTargetRole/source/CreateTargetRole_HdrSqs.js',
|
|
109
146
|
content: await renderRbacTemplate('CreateTargetRole_HdrSqs.ejs')
|
|
110
147
|
},
|
|
111
148
|
...webSocket.artifacts
|
|
112
149
|
],
|
|
113
150
|
functions: [
|
|
114
151
|
{
|
|
115
|
-
functionName: '
|
|
116
|
-
handlerPath:
|
|
152
|
+
functionName: 'CreateTargetRoleHdrSqs',
|
|
153
|
+
handlerPath:
|
|
154
|
+
'src/generatedCode/FlowRbac/CreateTargetRole/source/CreateTargetRole_HdrSqs.main',
|
|
117
155
|
roleName: 'FlowRbacRole',
|
|
118
|
-
queueName: '
|
|
156
|
+
queueName: 'CreateTargetRoleHdrSqs',
|
|
119
157
|
flowTag: 'CreateTargetRole',
|
|
120
158
|
flowStepName: ''
|
|
121
159
|
},
|
|
@@ -129,24 +167,36 @@ async function createListHandler(definition) {
|
|
|
129
167
|
const handlerPath = `src/generatedCode/FlowRbac/${definition.flowTag}/source`;
|
|
130
168
|
return {
|
|
131
169
|
artifacts: [
|
|
132
|
-
{
|
|
133
|
-
|
|
134
|
-
|
|
170
|
+
{
|
|
171
|
+
path: `${sourcePath}/${definition.flowTag}_Main.js`,
|
|
172
|
+
content: await renderRbacTemplate('ListRbac_Main.ejs', {
|
|
173
|
+
...definition,
|
|
174
|
+
useContextUserId: definition.useContextUserId ?? false
|
|
175
|
+
})
|
|
176
|
+
},
|
|
177
|
+
{
|
|
178
|
+
path: `${sourcePath}/${definition.flowTag}_HdrSqs.js`,
|
|
179
|
+
content: await renderRbacTemplate('ListRbac_HdrSqs.ejs', definition)
|
|
180
|
+
},
|
|
181
|
+
{
|
|
182
|
+
path: `${sourcePath}/${definition.flowTag}_HdrApi.js`,
|
|
183
|
+
content: await renderRbacTemplate('ListRbac_HdrApi.ejs', definition)
|
|
184
|
+
}
|
|
135
185
|
],
|
|
136
186
|
functions: [
|
|
137
187
|
{
|
|
138
188
|
type: 'sqs',
|
|
139
|
-
functionName:
|
|
140
|
-
handlerPath: `${handlerPath}
|
|
189
|
+
functionName: `${definition.flowTag}HdrSqs`,
|
|
190
|
+
handlerPath: `${handlerPath}/${definition.flowTag}_HdrSqs.main`,
|
|
141
191
|
roleName: 'FlowRbacRole',
|
|
142
|
-
queueName:
|
|
192
|
+
queueName: `${definition.flowTag}HdrSqs`,
|
|
143
193
|
flowTag: definition.flowTag,
|
|
144
194
|
flowStepName: ''
|
|
145
195
|
},
|
|
146
196
|
{
|
|
147
197
|
type: 'api',
|
|
148
|
-
functionName:
|
|
149
|
-
handlerPath: `${handlerPath}
|
|
198
|
+
functionName: `${definition.flowTag}HdrApi`,
|
|
199
|
+
handlerPath: `${handlerPath}/${definition.flowTag}_HdrApi.main`,
|
|
150
200
|
roleName: 'FlowRbacRole',
|
|
151
201
|
flowTag: definition.flowTag,
|
|
152
202
|
flowStepName: ''
|
|
@@ -158,20 +208,30 @@ async function createListHandler(definition) {
|
|
|
158
208
|
async function createMutationHandler(definition) {
|
|
159
209
|
const sourcePath = `app/src/generatedCode/FlowRbac/${definition.flowTag}/source`;
|
|
160
210
|
const handlerPath = `src/generatedCode/FlowRbac/${definition.flowTag}/source`;
|
|
161
|
-
const webSocket = await createWebSocketEntry(
|
|
211
|
+
const webSocket = await createWebSocketEntry(
|
|
212
|
+
definition.flowTag,
|
|
213
|
+
sourcePath,
|
|
214
|
+
handlerPath
|
|
215
|
+
);
|
|
162
216
|
return {
|
|
163
217
|
artifacts: [
|
|
164
|
-
{
|
|
165
|
-
|
|
218
|
+
{
|
|
219
|
+
path: `${sourcePath}/${definition.flowTag}_Main.js`,
|
|
220
|
+
content: await renderRbacTemplate('RbacMutation_Main.ejs', definition)
|
|
221
|
+
},
|
|
222
|
+
{
|
|
223
|
+
path: `${sourcePath}/${definition.flowTag}_HdrSqs.js`,
|
|
224
|
+
content: await renderRbacTemplate('ListRbac_HdrSqs.ejs', definition)
|
|
225
|
+
},
|
|
166
226
|
...webSocket.artifacts
|
|
167
227
|
],
|
|
168
228
|
functions: [
|
|
169
229
|
{
|
|
170
230
|
type: 'sqs',
|
|
171
|
-
functionName:
|
|
172
|
-
handlerPath: `${handlerPath}
|
|
231
|
+
functionName: `${definition.flowTag}HdrSqs`,
|
|
232
|
+
handlerPath: `${handlerPath}/${definition.flowTag}_HdrSqs.main`,
|
|
173
233
|
roleName: 'FlowRbacRole',
|
|
174
|
-
queueName:
|
|
234
|
+
queueName: `${definition.flowTag}HdrSqs`,
|
|
175
235
|
flowTag: definition.flowTag,
|
|
176
236
|
flowStepName: ''
|
|
177
237
|
},
|
|
@@ -183,20 +243,33 @@ async function createMutationHandler(definition) {
|
|
|
183
243
|
async function createUserRoleMutationHandler(definition) {
|
|
184
244
|
const sourcePath = `app/src/generatedCode/FlowRbac/${definition.flowTag}/source`;
|
|
185
245
|
const handlerPath = `src/generatedCode/FlowRbac/${definition.flowTag}/source`;
|
|
186
|
-
const webSocket = await createWebSocketEntry(
|
|
246
|
+
const webSocket = await createWebSocketEntry(
|
|
247
|
+
definition.flowTag,
|
|
248
|
+
sourcePath,
|
|
249
|
+
handlerPath
|
|
250
|
+
);
|
|
187
251
|
return {
|
|
188
252
|
artifacts: [
|
|
189
|
-
{
|
|
190
|
-
|
|
253
|
+
{
|
|
254
|
+
path: `${sourcePath}/${definition.flowTag}_Main.js`,
|
|
255
|
+
content: await renderRbacTemplate(
|
|
256
|
+
'UserRoleMutation_Main.ejs',
|
|
257
|
+
definition
|
|
258
|
+
)
|
|
259
|
+
},
|
|
260
|
+
{
|
|
261
|
+
path: `${sourcePath}/${definition.flowTag}_HdrSqs.js`,
|
|
262
|
+
content: await renderRbacTemplate('ListRbac_HdrSqs.ejs', definition)
|
|
263
|
+
},
|
|
191
264
|
...webSocket.artifacts
|
|
192
265
|
],
|
|
193
266
|
functions: [
|
|
194
267
|
{
|
|
195
268
|
type: 'sqs',
|
|
196
|
-
functionName:
|
|
197
|
-
handlerPath: `${handlerPath}
|
|
269
|
+
functionName: `${definition.flowTag}HdrSqs`,
|
|
270
|
+
handlerPath: `${handlerPath}/${definition.flowTag}_HdrSqs.main`,
|
|
198
271
|
roleName: 'FlowRbacRole',
|
|
199
|
-
queueName:
|
|
272
|
+
queueName: `${definition.flowTag}HdrSqs`,
|
|
200
273
|
flowTag: definition.flowTag,
|
|
201
274
|
flowStepName: ''
|
|
202
275
|
},
|
|
@@ -211,17 +284,28 @@ async function createUserRbacFlowHandler(object) {
|
|
|
211
284
|
const handlerPath = `src/generatedCode/FlowRbac/${flowTag}/source`;
|
|
212
285
|
return {
|
|
213
286
|
artifacts: [
|
|
214
|
-
{
|
|
215
|
-
|
|
287
|
+
{
|
|
288
|
+
path: `${sourcePath}/${flowTag}_Main.js`,
|
|
289
|
+
content: await renderRbacTemplate('UserRbacFlow_Main.ejs', { flowTag })
|
|
290
|
+
},
|
|
291
|
+
{
|
|
292
|
+
path: `${sourcePath}/${flowTag}_HdrSqs.js`,
|
|
293
|
+
content: await renderRbacTemplate('UserRbacFlow_HdrSqs.ejs', {
|
|
294
|
+
flowTag
|
|
295
|
+
})
|
|
296
|
+
}
|
|
216
297
|
],
|
|
217
|
-
functions: [
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
298
|
+
functions: [
|
|
299
|
+
{
|
|
300
|
+
type: 'sqs',
|
|
301
|
+
functionName: `${flowTag}HdrSqs`,
|
|
302
|
+
handlerPath: `${handlerPath}/${flowTag}_HdrSqs.main`,
|
|
303
|
+
roleName: 'FlowRbacRole',
|
|
304
|
+
queueName: `${flowTag}HdrSqs`,
|
|
305
|
+
flowTag: flowTag,
|
|
306
|
+
flowStepName: ''
|
|
307
|
+
}
|
|
308
|
+
]
|
|
225
309
|
};
|
|
226
310
|
}
|
|
227
311
|
|
|
@@ -233,27 +317,39 @@ function renderFunctionYaml(descriptor) {
|
|
|
233
317
|
}
|
|
234
318
|
|
|
235
319
|
async function createWebSocketEntry(flowTag, sourcePath, handlerPath) {
|
|
236
|
-
const mainFileName = `${flowTag}
|
|
320
|
+
const mainFileName = `${flowTag}_WbsMain`;
|
|
237
321
|
return {
|
|
238
322
|
artifacts: [
|
|
239
323
|
{
|
|
240
324
|
path: `${sourcePath}/${mainFileName}.js`,
|
|
241
|
-
content: await renderCrudTemplate('FlowMain_Wbs.ejs', {
|
|
325
|
+
content: await renderCrudTemplate('FlowMain_Wbs.ejs', {
|
|
326
|
+
flowTag,
|
|
327
|
+
functionName: flowTag,
|
|
328
|
+
upperCaseFlowTag: flowTag
|
|
329
|
+
})
|
|
242
330
|
},
|
|
243
331
|
{
|
|
244
332
|
path: `${sourcePath}/${flowTag}_HdrWbs.js`,
|
|
245
|
-
content: await renderCrudTemplate('FlowEndpoint_HdrWbs.ejs', {
|
|
333
|
+
content: await renderCrudTemplate('FlowEndpoint_HdrWbs.ejs', {
|
|
334
|
+
flowTag,
|
|
335
|
+
functionName: flowTag,
|
|
336
|
+
mainFileName,
|
|
337
|
+
upperCaseFlowTag: flowTag,
|
|
338
|
+
route: flowTag
|
|
339
|
+
})
|
|
246
340
|
}
|
|
247
341
|
],
|
|
248
|
-
functions: [
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
342
|
+
functions: [
|
|
343
|
+
{
|
|
344
|
+
type: 'wbs',
|
|
345
|
+
functionName: `${flowTag}HdrWbs`,
|
|
346
|
+
handlerPath: `${handlerPath}/${flowTag}_HdrWbs.main`,
|
|
347
|
+
roleName: 'FlowRbacRole',
|
|
348
|
+
routeName: flowTag,
|
|
349
|
+
flowTag: flowTag,
|
|
350
|
+
flowStepName: ''
|
|
351
|
+
}
|
|
352
|
+
]
|
|
257
353
|
};
|
|
258
354
|
}
|
|
259
355
|
|
|
@@ -266,5 +362,8 @@ function renderRbacTemplate(templateName, data = {}) {
|
|
|
266
362
|
}
|
|
267
363
|
|
|
268
364
|
async function renderTemplate(templateUrl, templateName, data) {
|
|
269
|
-
return ejs.render(
|
|
365
|
+
return ejs.render(
|
|
366
|
+
await readFile(new URL(templateName, templateUrl), 'utf8'),
|
|
367
|
+
data
|
|
368
|
+
);
|
|
270
369
|
}
|
|
@@ -1,24 +1,47 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright (C) 2020 Sven Mason <http://izara.io>
|
|
3
|
+
|
|
4
|
+
This program is free software: you can redistribute it and/or modify
|
|
5
|
+
it under the terms of the GNU Affero General Public License as
|
|
6
|
+
published by the Free Software Foundation, either version 3 of the
|
|
7
|
+
License, or (at your option) any later version.
|
|
8
|
+
|
|
9
|
+
This program is distributed in the hope that it will be useful,
|
|
10
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
12
|
+
GNU Affero General Public License for more details.
|
|
13
|
+
|
|
14
|
+
You should have received a copy of the GNU Affero General Public License
|
|
15
|
+
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
16
|
+
*/
|
|
17
|
+
|
|
1
18
|
import { middlewareHandler as middleware } from '@izara_project/izara-middleware';
|
|
2
19
|
import { recordHandlerSharedLib } from '@izara_project/izara-core-library-record-handler';
|
|
3
20
|
import callingFlowSharedLib from '@izara_project/izara-core-library-calling-flow';
|
|
4
|
-
import
|
|
21
|
+
import CreateTargetRole from './CreateTargetRole_Main.js';
|
|
5
22
|
|
|
6
23
|
middleware.setValidatorSchema(recordHandlerSharedLib.baseValidatorSchema());
|
|
7
24
|
|
|
8
|
-
export const main = middleware.wrap(async
|
|
9
|
-
|
|
10
|
-
record
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
+
export const main = middleware.wrap(async (event) =>
|
|
26
|
+
Promise.all(
|
|
27
|
+
event.Records.map(async (record) => {
|
|
28
|
+
await recordHandlerSharedLib.validateRecord(
|
|
29
|
+
record,
|
|
30
|
+
'CreateTargetRoleHdrSqs',
|
|
31
|
+
{},
|
|
32
|
+
null
|
|
33
|
+
);
|
|
34
|
+
return recordHandlerSharedLib.recordHandler(
|
|
35
|
+
record,
|
|
36
|
+
CreateTargetRole,
|
|
37
|
+
'CreateTargetRoleHdrSqs',
|
|
38
|
+
[
|
|
39
|
+
record.body.Message,
|
|
40
|
+
callingFlowSharedLib.addCallingFlowToPassOnProperties(
|
|
41
|
+
record.body.Message
|
|
42
|
+
)
|
|
43
|
+
]
|
|
44
|
+
);
|
|
45
|
+
})
|
|
46
|
+
)
|
|
47
|
+
);
|
|
@@ -1,10 +1,27 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright (C) 2020 Sven Mason <http://izara.io>
|
|
3
|
+
|
|
4
|
+
This program is free software: you can redistribute it and/or modify
|
|
5
|
+
it under the terms of the GNU Affero General Public License as
|
|
6
|
+
published by the Free Software Foundation, either version 3 of the
|
|
7
|
+
License, or (at your option) any later version.
|
|
8
|
+
|
|
9
|
+
This program is distributed in the hope that it will be useful,
|
|
10
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
12
|
+
GNU Affero General Public License for more details.
|
|
13
|
+
|
|
14
|
+
You should have received a copy of the GNU Affero General Public License
|
|
15
|
+
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
16
|
+
*/
|
|
17
|
+
|
|
1
18
|
import dynamodbSharedLib from '@izara_project/izara-core-library-dynamodb';
|
|
2
19
|
import snsSharedLib from '@izara_project/izara-core-library-sns';
|
|
3
20
|
import { sns } from '@izara_project/izara-core-library-external-request';
|
|
4
21
|
import { identifierUuid } from '@izara_project/izara-shared-core';
|
|
5
22
|
import { consts } from '@izara_project/izara-core-library-core';
|
|
6
23
|
|
|
7
|
-
export default async function
|
|
24
|
+
export default async function CreateTargetRole(_izContext, requestParams) {
|
|
8
25
|
try {
|
|
9
26
|
const userId = _izContext.correlationIds.get(consts.BASE_USER_ID);
|
|
10
27
|
const { roleName } = requestParams;
|
|
@@ -16,10 +33,13 @@ export default async function ProcessCreateTargetRole(_izContext, requestParams)
|
|
|
16
33
|
);
|
|
17
34
|
await sns.publishMessage(_izContext, {
|
|
18
35
|
message: { returnResult: { roleId } },
|
|
19
|
-
TopicArn: snsSharedLib.snsTopicArnByFlowSchema(
|
|
36
|
+
TopicArn: snsSharedLib.snsTopicArnByFlowSchema(
|
|
37
|
+
_izContext,
|
|
38
|
+
'CreateTargetRole_Out'
|
|
39
|
+
)
|
|
20
40
|
});
|
|
21
41
|
} catch (error) {
|
|
22
|
-
_izContext.logger.error('[Rbac:
|
|
42
|
+
_izContext.logger.error('[Rbac:CreateTargetRole] error:', error);
|
|
23
43
|
throw error;
|
|
24
44
|
}
|
|
25
45
|
}
|
|
@@ -1,16 +1,38 @@
|
|
|
1
|
-
|
|
1
|
+
/*
|
|
2
|
+
Copyright (C) 2020 Sven Mason <http://izara.io>
|
|
3
|
+
|
|
4
|
+
This program is free software: you can redistribute it and/or modify
|
|
5
|
+
it under the terms of the GNU Affero General Public License as
|
|
6
|
+
published by the Free Software Foundation, either version 3 of the
|
|
7
|
+
License, or (at your option) any later version.
|
|
8
|
+
|
|
9
|
+
This program is distributed in the hope that it will be useful,
|
|
10
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
12
|
+
GNU Affero General Public License for more details.
|
|
13
|
+
|
|
14
|
+
You should have received a copy of the GNU Affero General Public License
|
|
15
|
+
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
import {
|
|
19
|
+
middlewareHandler as middleware,
|
|
20
|
+
response
|
|
21
|
+
} from '@izara_project/izara-middleware';
|
|
2
22
|
import callingFlowSharedLib from '@izara_project/izara-core-library-calling-flow';
|
|
3
|
-
import
|
|
23
|
+
import <%- flowTag %> from './<%- flowTag %>_Main.js';
|
|
4
24
|
|
|
5
25
|
middleware.setValidatorSchema({}, { noAuthorizer: true });
|
|
6
|
-
export const main = middleware.wrap(async event => {
|
|
26
|
+
export const main = middleware.wrap(async (event) => {
|
|
7
27
|
try {
|
|
8
|
-
const result = await
|
|
28
|
+
const result = await <%- flowTag %>(
|
|
9
29
|
event._izContext,
|
|
10
30
|
event.body,
|
|
11
31
|
callingFlowSharedLib.addCallingFlowToPassOnProperties(event)
|
|
12
32
|
);
|
|
13
|
-
return result instanceof Error
|
|
33
|
+
return result instanceof Error
|
|
34
|
+
? response.failure(result)
|
|
35
|
+
: response.success(result);
|
|
14
36
|
} catch (error) {
|
|
15
37
|
return response.failure(error);
|
|
16
38
|
}
|
|
@@ -1,13 +1,46 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright (C) 2020 Sven Mason <http://izara.io>
|
|
3
|
+
|
|
4
|
+
This program is free software: you can redistribute it and/or modify
|
|
5
|
+
it under the terms of the GNU Affero General Public License as
|
|
6
|
+
published by the Free Software Foundation, either version 3 of the
|
|
7
|
+
License, or (at your option) any later version.
|
|
8
|
+
|
|
9
|
+
This program is distributed in the hope that it will be useful,
|
|
10
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
12
|
+
GNU Affero General Public License for more details.
|
|
13
|
+
|
|
14
|
+
You should have received a copy of the GNU Affero General Public License
|
|
15
|
+
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
16
|
+
*/
|
|
17
|
+
|
|
1
18
|
import { middlewareHandler as middleware } from '@izara_project/izara-middleware';
|
|
2
19
|
import { recordHandlerSharedLib } from '@izara_project/izara-core-library-record-handler';
|
|
3
20
|
import callingFlowSharedLib from '@izara_project/izara-core-library-calling-flow';
|
|
4
|
-
import
|
|
21
|
+
import <%- flowTag %> from './<%- flowTag %>_Main.js';
|
|
5
22
|
|
|
6
23
|
middleware.setValidatorSchema(recordHandlerSharedLib.baseValidatorSchema());
|
|
7
|
-
export const main = middleware.wrap(async
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
}
|
|
24
|
+
export const main = middleware.wrap(async (event) =>
|
|
25
|
+
Promise.all(
|
|
26
|
+
event.Records.map(async (record) => {
|
|
27
|
+
await recordHandlerSharedLib.validateRecord(
|
|
28
|
+
record,
|
|
29
|
+
'<%- flowTag %>HdrSqs',
|
|
30
|
+
{},
|
|
31
|
+
null
|
|
32
|
+
);
|
|
33
|
+
return recordHandlerSharedLib.recordHandler(
|
|
34
|
+
record,
|
|
35
|
+
<%- flowTag %>,
|
|
36
|
+
'<%- flowTag %>HdrSqs',
|
|
37
|
+
[
|
|
38
|
+
record.body.Message,
|
|
39
|
+
callingFlowSharedLib.addCallingFlowToPassOnProperties(
|
|
40
|
+
record.body.Message
|
|
41
|
+
)
|
|
42
|
+
]
|
|
43
|
+
);
|
|
44
|
+
})
|
|
45
|
+
)
|
|
46
|
+
);
|
|
@@ -1,18 +1,35 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright (C) 2020 Sven Mason <http://izara.io>
|
|
3
|
+
|
|
4
|
+
This program is free software: you can redistribute it and/or modify
|
|
5
|
+
it under the terms of the GNU Affero General Public License as
|
|
6
|
+
published by the Free Software Foundation, either version 3 of the
|
|
7
|
+
License, or (at your option) any later version.
|
|
8
|
+
|
|
9
|
+
This program is distributed in the hope that it will be useful,
|
|
10
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
12
|
+
GNU Affero General Public License for more details.
|
|
13
|
+
|
|
14
|
+
You should have received a copy of the GNU Affero General Public License
|
|
15
|
+
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
16
|
+
*/
|
|
17
|
+
|
|
1
18
|
import dynamodbSharedLib from '@izara_project/izara-core-library-dynamodb';
|
|
2
19
|
import snsSharedLib from '@izara_project/izara-core-library-sns';
|
|
3
20
|
import { sns } from '@izara_project/izara-core-library-external-request';
|
|
4
21
|
import { consts, NoRetryError } from '@izara_project/izara-core-library-core';
|
|
5
22
|
|
|
6
|
-
export default async function
|
|
23
|
+
export default async function <%- flowTag %>(_izContext, requestParams) {
|
|
7
24
|
try {
|
|
8
|
-
<% if (useContextUserId) { -%>
|
|
25
|
+
<% if (useContextUserId) { -%>
|
|
9
26
|
const userId = _izContext.correlationIds.get(consts.BASE_USER_ID);
|
|
10
27
|
if (!userId) throw new NoRetryError('User Id not found.');
|
|
11
28
|
const queryParams = { userId };
|
|
12
|
-
<% } else { -%>
|
|
29
|
+
<% } else { -%>
|
|
13
30
|
const { <%- requestProperty %> } = requestParams;
|
|
14
31
|
const queryParams = { <%- requestProperty %> };
|
|
15
|
-
<% } -%>
|
|
32
|
+
<% } -%>
|
|
16
33
|
const resultQuery = await dynamodbSharedLib.query(
|
|
17
34
|
_izContext,
|
|
18
35
|
dynamodbSharedLib.tableName(_izContext, '<%- tableName %>'),
|
|
@@ -20,10 +37,13 @@ export default async function Process<%- flowTag %>(_izContext, requestParams) {
|
|
|
20
37
|
);
|
|
21
38
|
await sns.publishMessage(_izContext, {
|
|
22
39
|
message: { returnResult: { records: resultQuery.Items || [] } },
|
|
23
|
-
TopicArn: snsSharedLib.snsTopicArnByFlowSchema(
|
|
40
|
+
TopicArn: snsSharedLib.snsTopicArnByFlowSchema(
|
|
41
|
+
_izContext,
|
|
42
|
+
'<%- flowTag %>_Out'
|
|
43
|
+
)
|
|
24
44
|
});
|
|
25
45
|
} catch (error) {
|
|
26
|
-
_izContext.logger.error('[Rbac
|
|
46
|
+
_izContext.logger.error('[Rbac:<%- flowTag %>] error:', error);
|
|
27
47
|
throw error;
|
|
28
48
|
}
|
|
29
49
|
}
|