@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.
- package/.prettierrc +11 -0
- package/docs/TriggeredCache Flow.drawio +193 -0
- package/docs/TriggeredCacheFlow.mmd +47 -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 +108 -1
- package/src/emit/crud/emitCrudApplicationArtifacts.js +9 -5
- package/src/emit/crud/emitDynamicCrudFlowSchemas.js +1 -2
- package/src/emit/crud/templates/CreateEndpoint_Main.ejs +300 -109
- package/src/emit/crud/templates/DeleteEndpoint_Main.ejs +221 -143
- package/src/emit/crud/templates/FlowEndpointBeforeLogical_Main.ejs +22 -6
- package/src/emit/crud/templates/FlowEndpointComplete_Main.ejs +150 -38
- package/src/emit/crud/templates/FlowEndpoint_HdrWbs.ejs +51 -31
- package/src/emit/crud/templates/FlowHandler_HdrApi.ejs +57 -31
- 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 +6 -3
- package/src/emit/crud/templates/GetRangeEndpoint_Main.ejs +2 -2
- package/src/emit/crud/templates/UpdateEndpoint_Main.ejs +407 -252
- package/src/emit/custom/customFlows.js +112 -31
- package/src/emit/custom/emitCustomFlowApplicationArtifacts.js +89 -77
- package/src/emit/custom/templates/FlowEndpoint_Main.ejs +49 -37
- 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 +46 -12
- package/src/emit/rbac/emitDynamicRbacFlowSchemas.js +28 -15
- package/src/emit/rbac/emitRbacApplicationArtifacts.js +179 -66
- 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/emitRelationshipApplicationArtifacts.js +6 -5
- package/src/emit/relationship/templates/ChangeRelationshipComplete_Main.ejs +64 -37
- package/src/emit/relationship/templates/ChangeRelationship_Main.ejs +260 -144
- 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 +499 -108
- 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/emit/system/emitSystemWebSocketArtifacts.js +2 -1
- package/src/generate.js +8 -4
- package/test/createTargetRoleHandler.test.js +63 -14
- package/test/crudApplicationArtifacts.test.js +1 -1
- package/test/customFlowApplicationArtifacts.test.js +71 -43
- 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 +11 -13
- package/test/resourceArtifacts.test.js +13 -3
- package/src/emit/rbac/templates/UserRbacFlow_HdrInv.ejs +0 -10
|
@@ -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,40 @@ 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',
|
|
157
|
+
flowTag: 'CreateTargetRole',
|
|
158
|
+
flowStepName: ''
|
|
119
159
|
},
|
|
120
160
|
...webSocket.functions
|
|
121
161
|
]
|
|
@@ -127,23 +167,39 @@ async function createListHandler(definition) {
|
|
|
127
167
|
const handlerPath = `src/generatedCode/FlowRbac/${definition.flowTag}/source`;
|
|
128
168
|
return {
|
|
129
169
|
artifacts: [
|
|
130
|
-
{
|
|
131
|
-
|
|
132
|
-
|
|
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
|
+
}
|
|
133
185
|
],
|
|
134
186
|
functions: [
|
|
135
187
|
{
|
|
136
188
|
type: 'sqs',
|
|
137
|
-
functionName:
|
|
138
|
-
handlerPath: `${handlerPath}
|
|
189
|
+
functionName: `${definition.flowTag}HdrSqs`,
|
|
190
|
+
handlerPath: `${handlerPath}/${definition.flowTag}_HdrSqs.main`,
|
|
139
191
|
roleName: 'FlowRbacRole',
|
|
140
|
-
queueName:
|
|
192
|
+
queueName: `${definition.flowTag}HdrSqs`,
|
|
193
|
+
flowTag: definition.flowTag,
|
|
194
|
+
flowStepName: ''
|
|
141
195
|
},
|
|
142
196
|
{
|
|
143
197
|
type: 'api',
|
|
144
|
-
functionName:
|
|
145
|
-
handlerPath: `${handlerPath}
|
|
146
|
-
roleName: 'FlowRbacRole'
|
|
198
|
+
functionName: `${definition.flowTag}HdrApi`,
|
|
199
|
+
handlerPath: `${handlerPath}/${definition.flowTag}_HdrApi.main`,
|
|
200
|
+
roleName: 'FlowRbacRole',
|
|
201
|
+
flowTag: definition.flowTag,
|
|
202
|
+
flowStepName: ''
|
|
147
203
|
}
|
|
148
204
|
]
|
|
149
205
|
};
|
|
@@ -152,20 +208,32 @@ async function createListHandler(definition) {
|
|
|
152
208
|
async function createMutationHandler(definition) {
|
|
153
209
|
const sourcePath = `app/src/generatedCode/FlowRbac/${definition.flowTag}/source`;
|
|
154
210
|
const handlerPath = `src/generatedCode/FlowRbac/${definition.flowTag}/source`;
|
|
155
|
-
const webSocket = await createWebSocketEntry(
|
|
211
|
+
const webSocket = await createWebSocketEntry(
|
|
212
|
+
definition.flowTag,
|
|
213
|
+
sourcePath,
|
|
214
|
+
handlerPath
|
|
215
|
+
);
|
|
156
216
|
return {
|
|
157
217
|
artifacts: [
|
|
158
|
-
{
|
|
159
|
-
|
|
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
|
+
},
|
|
160
226
|
...webSocket.artifacts
|
|
161
227
|
],
|
|
162
228
|
functions: [
|
|
163
229
|
{
|
|
164
230
|
type: 'sqs',
|
|
165
|
-
functionName:
|
|
166
|
-
handlerPath: `${handlerPath}
|
|
231
|
+
functionName: `${definition.flowTag}HdrSqs`,
|
|
232
|
+
handlerPath: `${handlerPath}/${definition.flowTag}_HdrSqs.main`,
|
|
167
233
|
roleName: 'FlowRbacRole',
|
|
168
|
-
queueName:
|
|
234
|
+
queueName: `${definition.flowTag}HdrSqs`,
|
|
235
|
+
flowTag: definition.flowTag,
|
|
236
|
+
flowStepName: ''
|
|
169
237
|
},
|
|
170
238
|
...webSocket.functions
|
|
171
239
|
]
|
|
@@ -175,20 +243,35 @@ async function createMutationHandler(definition) {
|
|
|
175
243
|
async function createUserRoleMutationHandler(definition) {
|
|
176
244
|
const sourcePath = `app/src/generatedCode/FlowRbac/${definition.flowTag}/source`;
|
|
177
245
|
const handlerPath = `src/generatedCode/FlowRbac/${definition.flowTag}/source`;
|
|
178
|
-
const webSocket = await createWebSocketEntry(
|
|
246
|
+
const webSocket = await createWebSocketEntry(
|
|
247
|
+
definition.flowTag,
|
|
248
|
+
sourcePath,
|
|
249
|
+
handlerPath
|
|
250
|
+
);
|
|
179
251
|
return {
|
|
180
252
|
artifacts: [
|
|
181
|
-
{
|
|
182
|
-
|
|
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
|
+
},
|
|
183
264
|
...webSocket.artifacts
|
|
184
265
|
],
|
|
185
266
|
functions: [
|
|
186
267
|
{
|
|
187
268
|
type: 'sqs',
|
|
188
|
-
functionName:
|
|
189
|
-
handlerPath: `${handlerPath}
|
|
269
|
+
functionName: `${definition.flowTag}HdrSqs`,
|
|
270
|
+
handlerPath: `${handlerPath}/${definition.flowTag}_HdrSqs.main`,
|
|
190
271
|
roleName: 'FlowRbacRole',
|
|
191
|
-
queueName:
|
|
272
|
+
queueName: `${definition.flowTag}HdrSqs`,
|
|
273
|
+
flowTag: definition.flowTag,
|
|
274
|
+
flowStepName: ''
|
|
192
275
|
},
|
|
193
276
|
...webSocket.functions
|
|
194
277
|
]
|
|
@@ -201,15 +284,28 @@ async function createUserRbacFlowHandler(object) {
|
|
|
201
284
|
const handlerPath = `src/generatedCode/FlowRbac/${flowTag}/source`;
|
|
202
285
|
return {
|
|
203
286
|
artifacts: [
|
|
204
|
-
{
|
|
205
|
-
|
|
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
|
+
}
|
|
206
297
|
],
|
|
207
|
-
functions: [
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
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
|
+
]
|
|
213
309
|
};
|
|
214
310
|
}
|
|
215
311
|
|
|
@@ -221,25 +317,39 @@ function renderFunctionYaml(descriptor) {
|
|
|
221
317
|
}
|
|
222
318
|
|
|
223
319
|
async function createWebSocketEntry(flowTag, sourcePath, handlerPath) {
|
|
224
|
-
const mainFileName = `${flowTag}
|
|
320
|
+
const mainFileName = `${flowTag}_WbsMain`;
|
|
225
321
|
return {
|
|
226
322
|
artifacts: [
|
|
227
323
|
{
|
|
228
324
|
path: `${sourcePath}/${mainFileName}.js`,
|
|
229
|
-
content: await renderCrudTemplate('FlowMain_Wbs.ejs', {
|
|
325
|
+
content: await renderCrudTemplate('FlowMain_Wbs.ejs', {
|
|
326
|
+
flowTag,
|
|
327
|
+
functionName: flowTag,
|
|
328
|
+
upperCaseFlowTag: flowTag
|
|
329
|
+
})
|
|
230
330
|
},
|
|
231
331
|
{
|
|
232
332
|
path: `${sourcePath}/${flowTag}_HdrWbs.js`,
|
|
233
|
-
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
|
+
})
|
|
234
340
|
}
|
|
235
341
|
],
|
|
236
|
-
functions: [
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
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
|
+
]
|
|
243
353
|
};
|
|
244
354
|
}
|
|
245
355
|
|
|
@@ -252,5 +362,8 @@ function renderRbacTemplate(templateName, data = {}) {
|
|
|
252
362
|
}
|
|
253
363
|
|
|
254
364
|
async function renderTemplate(templateUrl, templateName, data) {
|
|
255
|
-
return ejs.render(
|
|
365
|
+
return ejs.render(
|
|
366
|
+
await readFile(new URL(templateName, templateUrl), 'utf8'),
|
|
367
|
+
data
|
|
368
|
+
);
|
|
256
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
|
}
|