@izara_project/izara-core-generate-service-code 1.0.72 → 1.0.74
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/package.json +3 -2
- package/src/emit/coreFunction/emitCoreFunctionArtifacts.js +3 -0
- package/src/emit/coreFunction/templates/InitialSetupConfig.ejs +100 -28
- package/src/emit/coreFunction/templates/InitialSetupRunner.ejs +4 -2
- package/src/emit/coreFunction/templates/InitialSetupRunner_uploadSchema.ejs +2 -0
- package/src/emit/coreFunction/templates/UploadSchema_Main.ejs +2 -0
- package/src/emit/custom/customFlows.js +42 -0
- package/src/emit/custom/emitCustomFlowApplicationArtifacts.js +44 -14
- package/src/emit/custom/templates/triggerCache/CheckTriggerCache_HdrSqs.ejs +15 -10
- package/src/emit/function/functionYamlArtifact.js +8 -3
- package/src/emit/relationship/templates/ChangeRelationshipComplete_Main.ejs +8 -13
- package/src/emit/relationship/templates/ChangeRelationship_Main.ejs +5 -14
- package/src/emit/relationship/templates/CreateRelationshipComplete_Main.ejs +8 -13
- package/src/emit/relationship/templates/CreateRelationship_Main.ejs +7 -16
- package/src/emit/relationship/templates/DeleteRelationshipComplete_Main.ejs +8 -4
- package/src/emit/relationship/templates/DeleteRelationship_Main.ejs +6 -24
- package/src/emit/relationship/templates/GetRelationshipComplete_Main.ejs +8 -4
- package/src/emit/relationship/templates/MoveRelationshipComplete_Main.ejs +8 -15
- package/src/emit/relationship/templates/MoveRelationship_Main.ejs +6 -15
- package/src/emit/relationship/templates/UpdateRelationshipComplete_Main.ejs +9 -31
- package/src/emit/relationship/templates/UpdateRelationship_Main.ejs +6 -15
- package/src/emit/resource/emitResourceArtifacts.js +2 -1
- package/src/emit/resource/templates/DynamoDBTable_Yaml.ejs +3 -0
- package/src/emit/shared/templates/FlowHandler_HdrApi.ejs +6 -6
- package/src/emit/shared/templates/FlowHandler_HdrDsq.ejs +18 -13
- package/src/emit/shared/templates/FlowHandler_HdrInv.ejs +6 -6
- package/src/emit/shared/templates/FlowHandler_HdrSqs.ejs +18 -13
- package/src/emit/system/templates/WebSocketComplete_Yaml.ejs +2 -0
- package/test/crudApplicationArtifacts.test.js +22 -0
- package/test/customFlowApplicationArtifacts.test.js +206 -0
- package/test/functionYamlArtifact.test.js +5 -2
- package/test/publicApi.test.js +29 -0
- package/test/relationshipApplicationArtifacts.test.js +42 -8
- package/test/resourceArtifacts.test.js +34 -16
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@izara_project/izara-core-generate-service-code",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.74",
|
|
4
4
|
"description": "Code for locally generating per service files",
|
|
5
5
|
"homepage": "https://bitbucket.org/izara-core-support-services/izara-core-support-services-generate-service-code#readme",
|
|
6
6
|
"repository": {
|
|
@@ -26,12 +26,13 @@
|
|
|
26
26
|
"@izara_project/izara-shared-core": "^1.0.13",
|
|
27
27
|
"ejs": "^6.0.1",
|
|
28
28
|
"js-beautify": "^2.0.3",
|
|
29
|
+
"ws": "^8.21.2",
|
|
29
30
|
"yaml": "^2.9.0"
|
|
30
31
|
},
|
|
31
32
|
"devDependencies": {
|
|
32
33
|
"@izara_project/izara-core-library-logger": "^1.0.11",
|
|
33
34
|
"@izara_project/izara-core-library-service-schemas": "1.0.161",
|
|
34
|
-
"@izara_project/izara-shared-service-schemas": "^1.0.
|
|
35
|
+
"@izara_project/izara-shared-service-schemas": "^1.0.70",
|
|
35
36
|
"jest": "^30.4.2",
|
|
36
37
|
"prettier": "^3.9.6",
|
|
37
38
|
"prettier-plugin-ejs": "^1.0.3"
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import ejsLib from 'ejs';
|
|
2
2
|
import { readFile } from 'node:fs/promises';
|
|
3
3
|
|
|
4
|
+
import { customFlowNextSteps } from '../custom/customFlows.js';
|
|
5
|
+
|
|
4
6
|
const TEMPLATE_URL = new URL('./templates/', import.meta.url);
|
|
5
7
|
const APP_ROOT = 'app/sls_yaml/generatedCode/source';
|
|
6
8
|
const SRC_ROOT = 'app/src/generatedCode/CoreFunctions';
|
|
@@ -94,6 +96,7 @@ export async function emitCoreFunctionArtifacts({ project, objects = [], relatio
|
|
|
94
96
|
objects,
|
|
95
97
|
relationships,
|
|
96
98
|
flows,
|
|
99
|
+
customFlowNextSteps: customFlowNextSteps(flows),
|
|
97
100
|
objectGraphServiceTags,
|
|
98
101
|
relationshipGraphServiceTags,
|
|
99
102
|
crud,
|
|
@@ -50,9 +50,9 @@ const externalServices = {
|
|
|
50
50
|
const tableConfigs = {
|
|
51
51
|
prod: {
|
|
52
52
|
Config: {},
|
|
53
|
-
|
|
54
|
-
<%= tableName %>: {}
|
|
55
|
-
|
|
53
|
+
<% dynamoTableNames.forEach(tableName => { -%>
|
|
54
|
+
<%= tableName %>: {},
|
|
55
|
+
<% }); -%>
|
|
56
56
|
// <#InitialSetupConfig_ExtraProdTableConfigs#>
|
|
57
57
|
// <#/InitialSetupConfig_ExtraProdTableConfigs#>
|
|
58
58
|
},
|
|
@@ -61,11 +61,11 @@ const tableConfigs = {
|
|
|
61
61
|
clearDataWhenRefresh: true,
|
|
62
62
|
rawSource: false
|
|
63
63
|
},
|
|
64
|
-
|
|
64
|
+
<% dynamoTableNames.forEach(tableName => { -%>
|
|
65
65
|
<%= tableName %>: {
|
|
66
66
|
clearDataWhenRefresh: true
|
|
67
|
-
}
|
|
68
|
-
|
|
67
|
+
},
|
|
68
|
+
<% }); -%>
|
|
69
69
|
// <#InitialSetupConfig_ExtraTestTableConfigs#>
|
|
70
70
|
// <#/InitialSetupConfig_ExtraTestTableConfigs#>
|
|
71
71
|
}
|
|
@@ -91,31 +91,31 @@ const tableConfigs = {
|
|
|
91
91
|
});
|
|
92
92
|
-%>
|
|
93
93
|
const snsTopicSubscriptions = [
|
|
94
|
-
|
|
94
|
+
<% if (relSubs.length > 0) { -%>
|
|
95
95
|
// ------------------------------------------------------------
|
|
96
96
|
// Relationship Subscriptions
|
|
97
97
|
// ------------------------------------------------------------
|
|
98
|
-
|
|
98
|
+
<% relSubs.forEach(function(sub, idx) { -%>
|
|
99
99
|
{
|
|
100
100
|
serviceTag: '<%= sub.serviceTag %>',
|
|
101
101
|
topicName: '<%= sub.topicName %>',
|
|
102
102
|
sqsEndpoint: '<%= sub.sqsEndpoint %>'
|
|
103
103
|
},
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
104
|
+
<% }); -%>
|
|
105
|
+
<% } -%>
|
|
106
|
+
<% if (nodeSubs.length > 0) { -%>
|
|
107
107
|
|
|
108
108
|
// ------------------------------------------------------------
|
|
109
109
|
// Node Subscriptions
|
|
110
110
|
// ------------------------------------------------------------
|
|
111
|
-
|
|
111
|
+
<% nodeSubs.forEach(function(sub, idx) { -%>
|
|
112
112
|
{
|
|
113
113
|
serviceTag: '<%= sub.serviceTag %>',
|
|
114
114
|
topicName: '<%= sub.topicName %>',
|
|
115
115
|
sqsEndpoint: '<%= sub.sqsEndpoint %>'
|
|
116
116
|
},
|
|
117
|
-
|
|
118
|
-
|
|
117
|
+
<% }); -%>
|
|
118
|
+
<% } -%>
|
|
119
119
|
|
|
120
120
|
//(<additionalSubscription>)
|
|
121
121
|
//(</additionalSubscription>)
|
|
@@ -126,11 +126,11 @@ const snsTopicSubscriptions = [
|
|
|
126
126
|
// ============================================================
|
|
127
127
|
function roleConfigs() {
|
|
128
128
|
const externalLambdaRole = [
|
|
129
|
-
|
|
129
|
+
<% if (crud && objectGraphServiceTags && objectGraphServiceTags.length > 0) { -%>
|
|
130
130
|
{
|
|
131
131
|
roleName: 'FlowObjects',
|
|
132
132
|
statement: [
|
|
133
|
-
|
|
133
|
+
<% objectGraphServiceTags.forEach(function(tag, idx) { -%>
|
|
134
134
|
{
|
|
135
135
|
Sid: 'FlowObjectsInvokeGetNode<%= tag %>',
|
|
136
136
|
Effect: 'Allow',
|
|
@@ -149,7 +149,7 @@ function roleConfigs() {
|
|
|
149
149
|
`arn:aws:sns:${process.env.iz_region}:${process.env.iz_accountId}:${snsSharedLib.snsTopicNameByFlowSchema(_izContext, 'CreateNode_In', '<%= tag %>')}`
|
|
150
150
|
]
|
|
151
151
|
},
|
|
152
|
-
|
|
152
|
+
<% }); -%>
|
|
153
153
|
//(<createFlowObjectsRole>)
|
|
154
154
|
//(</createFlowObjectsRole>)
|
|
155
155
|
]
|
|
@@ -158,7 +158,7 @@ function roleConfigs() {
|
|
|
158
158
|
{
|
|
159
159
|
roleName: 'ProcFindData',
|
|
160
160
|
statement: [
|
|
161
|
-
|
|
161
|
+
<% objectGraphServiceTags.forEach(function(tag, idx) { -%>
|
|
162
162
|
{
|
|
163
163
|
Sid: 'ProcFindDataInvokeGetNode<%= tag %>',
|
|
164
164
|
Effect: 'Allow',
|
|
@@ -167,18 +167,17 @@ function roleConfigs() {
|
|
|
167
167
|
`arn:aws:lambda:${process.env.iz_region}:${process.env.iz_accountId}:function:${lambdaSharedLib.lambdaFunctionName(_izContext, 'GetNodeHdrInv', '<%= tag %>')}`
|
|
168
168
|
]
|
|
169
169
|
}
|
|
170
|
-
|
|
170
|
+
<% }); -%>
|
|
171
171
|
//(<createProcFindDataRole>)
|
|
172
172
|
//(</createProcFindDataRole>)
|
|
173
173
|
]
|
|
174
174
|
},
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
<% if (hasRelationships && relationshipGraphServiceTags && relationshipGraphServiceTags.length > 0) { -%>
|
|
175
|
+
<% } -%>
|
|
176
|
+
<% if (hasRelationships && relationshipGraphServiceTags && relationshipGraphServiceTags.length > 0) { -%>
|
|
178
177
|
{
|
|
179
178
|
roleName: 'FlowRelationship',
|
|
180
179
|
statement: [
|
|
181
|
-
|
|
180
|
+
<% relationshipGraphServiceTags.forEach(function(tag, idx) { -%>
|
|
182
181
|
{
|
|
183
182
|
Sid: 'FlowRelationshipInvokeGetRelationship<%= tag %>',
|
|
184
183
|
Effect: 'Allow',
|
|
@@ -200,13 +199,14 @@ function roleConfigs() {
|
|
|
200
199
|
`arn:aws:sns:${process.env.iz_region}:${process.env.iz_accountId}:${snsSharedLib.snsTopicNameByFlowSchema(_izContext, 'MoveRelationship_In', '<%= tag %>')}`
|
|
201
200
|
]
|
|
202
201
|
}
|
|
203
|
-
|
|
202
|
+
<% }); -%>
|
|
204
203
|
//(<createFlowRelationshipRole>)
|
|
205
204
|
//(</createFlowRelationshipRole>)
|
|
206
205
|
]
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
|
|
206
|
+
},
|
|
207
|
+
<% } -%>
|
|
208
|
+
<% s3Flows.forEach(function(flow) { -%>
|
|
209
|
+
{
|
|
210
210
|
roleName: '<%= flow.roleName %>',
|
|
211
211
|
statement: [
|
|
212
212
|
{
|
|
@@ -229,7 +229,79 @@ function roleConfigs() {
|
|
|
229
229
|
//(<create<%= flow.roleName %>Role>)
|
|
230
230
|
//(</create<%= flow.roleName %>Role>)
|
|
231
231
|
]
|
|
232
|
-
}
|
|
232
|
+
},
|
|
233
|
+
<% }); -%>
|
|
234
|
+
<%
|
|
235
|
+
let nextStepsFlows = [];
|
|
236
|
+
if (typeof customFlowNextSteps !== 'undefined' && customFlowNextSteps) {
|
|
237
|
+
nextStepsFlows = customFlowNextSteps;
|
|
238
|
+
}
|
|
239
|
+
for (let flowIdx = 0; flowIdx < nextStepsFlows.length; flowIdx++) {
|
|
240
|
+
const flow = nextStepsFlows[flowIdx];
|
|
241
|
+
const snsTopicItems = [];
|
|
242
|
+
const lambdaInvItems = [];
|
|
243
|
+
for (const s of flow.nextSteps) {
|
|
244
|
+
if (s.targetType === 'extTopic' || s.targetType === 'ownTopic') {
|
|
245
|
+
snsTopicItems.push(s);
|
|
246
|
+
} else if (s.targetType === 'lambdaSyncInv') {
|
|
247
|
+
lambdaInvItems.push(s);
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
-%>
|
|
251
|
+
{
|
|
252
|
+
roleName: '<%= flow.roleName %>',
|
|
253
|
+
statement: [
|
|
254
|
+
<% if (snsTopicItems.length > 0) { -%>
|
|
255
|
+
{
|
|
256
|
+
Sid: '<%= flow.roleName %>PublishNextStepsTopics',
|
|
257
|
+
Effect: 'Allow',
|
|
258
|
+
Action: ['sns:Publish'],
|
|
259
|
+
Resource: [
|
|
260
|
+
<%
|
|
261
|
+
for (let idx = 0; idx < snsTopicItems.length; idx++) {
|
|
262
|
+
const item = snsTopicItems[idx];
|
|
263
|
+
let tagArg = '';
|
|
264
|
+
if (item.serviceTag) {
|
|
265
|
+
tagArg = `, '${item.serviceTag}'`;
|
|
266
|
+
}
|
|
267
|
+
let comma = '';
|
|
268
|
+
if (idx < snsTopicItems.length - 1) {
|
|
269
|
+
comma = ',';
|
|
270
|
+
}
|
|
271
|
+
-%>
|
|
272
|
+
`arn:aws:sns:${process.env.iz_region}:${process.env.iz_accountId}:${snsSharedLib.snsTopicNameByFlowSchema(_izContext, '<%- item.topic %>'<%- tagArg %>)}`<%= comma %>
|
|
273
|
+
<% } -%>
|
|
274
|
+
]
|
|
275
|
+
}<% if (lambdaInvItems.length > 0) { %>,<% } %>
|
|
276
|
+
<% } -%>
|
|
277
|
+
<% if (lambdaInvItems.length > 0) { -%>
|
|
278
|
+
{
|
|
279
|
+
Sid: '<%= flow.roleName %>InvokeNextStepsFunctions',
|
|
280
|
+
Effect: 'Allow',
|
|
281
|
+
Action: ['lambda:InvokeFunction'],
|
|
282
|
+
Resource: [
|
|
283
|
+
<%
|
|
284
|
+
for (let idx = 0; idx < lambdaInvItems.length; idx++) {
|
|
285
|
+
const item = lambdaInvItems[idx];
|
|
286
|
+
let tagArg = '';
|
|
287
|
+
if (item.serviceTag) {
|
|
288
|
+
tagArg = `, '${item.serviceTag}'`;
|
|
289
|
+
}
|
|
290
|
+
let comma = '';
|
|
291
|
+
if (idx < lambdaInvItems.length - 1) {
|
|
292
|
+
comma = ',';
|
|
293
|
+
}
|
|
294
|
+
-%>
|
|
295
|
+
`arn:aws:lambda:${process.env.iz_region}:${process.env.iz_accountId}:function:${lambdaSharedLib.lambdaFunctionName(_izContext, '<%- item.topic %>'<%- tagArg %>)}`<%= comma %>
|
|
296
|
+
<% } -%>
|
|
297
|
+
]
|
|
298
|
+
}
|
|
299
|
+
<% } -%>
|
|
300
|
+
//(<create<%= flow.roleName %>Role>)
|
|
301
|
+
//(</create<%= flow.roleName %>Role>)
|
|
302
|
+
]
|
|
303
|
+
}<% if (flowIdx < nextStepsFlows.length - 1) { %>,<% } %>
|
|
304
|
+
<% } -%>
|
|
233
305
|
//(<additionalRole>)
|
|
234
306
|
//(</additionalRole>)
|
|
235
307
|
];
|
|
@@ -27,6 +27,8 @@ if (fs.existsSync(configPath)) {
|
|
|
27
27
|
process.env.iz_accountId = izConfig.iz_accountId || process.env.iz_accountId;
|
|
28
28
|
process.env.iz_serviceTag =
|
|
29
29
|
izConfig.iz_serviceTag || process.env.iz_serviceTag;
|
|
30
|
+
process.env.iz_serviceSchemaBucketName =
|
|
31
|
+
izConfig.iz_serviceSchemaBucketName || process.env.iz_serviceSchemaBucketName;
|
|
30
32
|
process.env.iz_resourcePrefix =
|
|
31
33
|
izConfig.iz_resourcePrefix ||
|
|
32
34
|
process.env.iz_resourcePrefix ||
|
|
@@ -53,11 +55,11 @@ function _createContext() {
|
|
|
53
55
|
_izContext.correlationIds = new CorrelationIds();
|
|
54
56
|
_izContext.correlationIds.set(
|
|
55
57
|
consts.BASE_USER_ID,
|
|
56
|
-
process.env.iz_userId || ''
|
|
58
|
+
process.env.iz_userId || 'system'
|
|
57
59
|
);
|
|
58
60
|
_izContext.correlationIds.set(
|
|
59
61
|
consts.RESOURCE_USE_USER_ID,
|
|
60
|
-
process.env.iz_userId || ''
|
|
62
|
+
process.env.iz_userId || 'system'
|
|
61
63
|
);
|
|
62
64
|
_izContext.logger = Logger;
|
|
63
65
|
return _izContext;
|
|
@@ -8,6 +8,7 @@ const SERVICE_TAG = {
|
|
|
8
8
|
MEDIA: 'Media'
|
|
9
9
|
};
|
|
10
10
|
|
|
11
|
+
//(<ignoreExternalServices>)
|
|
11
12
|
const ignoreExternalServices = {
|
|
12
13
|
[SERVICE_TAG.TRANSLATIONS]: false,
|
|
13
14
|
[SERVICE_TAG.GRAPH_HANDLER]: false,
|
|
@@ -15,6 +16,7 @@ const ignoreExternalServices = {
|
|
|
15
16
|
[SERVICE_TAG.TRANSLATE_IDS]: false,
|
|
16
17
|
[SERVICE_TAG.MEDIA]: false
|
|
17
18
|
};
|
|
19
|
+
//(</ignoreExternalServices>)
|
|
18
20
|
|
|
19
21
|
export default async function uploadSchema(_izContext) {
|
|
20
22
|
console.log('======== UploadSchema ========');
|
|
@@ -25,6 +25,7 @@ const SERVICE_TAG = {
|
|
|
25
25
|
MEDIA: 'Media'
|
|
26
26
|
};
|
|
27
27
|
|
|
28
|
+
//(<ignoreExternalServices>)
|
|
28
29
|
const ignoreExternalServices = {
|
|
29
30
|
[SERVICE_TAG.TRANSLATIONS]: false,
|
|
30
31
|
[SERVICE_TAG.GRAPH_HANDLER]: false,
|
|
@@ -32,6 +33,7 @@ const ignoreExternalServices = {
|
|
|
32
33
|
[SERVICE_TAG.TRANSLATE_IDS]: false,
|
|
33
34
|
[SERVICE_TAG.MEDIA]: false
|
|
34
35
|
};
|
|
36
|
+
//(</ignoreExternalServices>)
|
|
35
37
|
|
|
36
38
|
const uploadSchema = async (_izContext) => {
|
|
37
39
|
try {
|
|
@@ -159,3 +159,45 @@ export function triggerCacheQueueNames(flow) {
|
|
|
159
159
|
}
|
|
160
160
|
return queues;
|
|
161
161
|
}
|
|
162
|
+
|
|
163
|
+
function _stepNextSteps(step) {
|
|
164
|
+
if (!step || !Array.isArray(step.nextSteps)) {
|
|
165
|
+
return [];
|
|
166
|
+
}
|
|
167
|
+
return step.nextSteps.filter(
|
|
168
|
+
(item) =>
|
|
169
|
+
typeof item === 'object' &&
|
|
170
|
+
item !== null &&
|
|
171
|
+
typeof item.targetType === 'string'
|
|
172
|
+
);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
export function customFlowNextSteps(flows) {
|
|
176
|
+
if (!Array.isArray(flows)) {
|
|
177
|
+
return [];
|
|
178
|
+
}
|
|
179
|
+
const results = [];
|
|
180
|
+
for (const flow of flows) {
|
|
181
|
+
if (typeof flow?.flowTag !== 'string' || flow.flowTag === '') {
|
|
182
|
+
continue;
|
|
183
|
+
}
|
|
184
|
+
const roleName = customFlowRoleName(flow.flowTag);
|
|
185
|
+
const steps = flow.flowSteps ?? [];
|
|
186
|
+
const nextStepsList = [];
|
|
187
|
+
for (const step of steps) {
|
|
188
|
+
const items = _stepNextSteps(step);
|
|
189
|
+
for (const item of items) {
|
|
190
|
+
nextStepsList.push(item);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
if (nextStepsList.length > 0) {
|
|
194
|
+
results.push({
|
|
195
|
+
flowTag: flow.flowTag,
|
|
196
|
+
roleName,
|
|
197
|
+
nextSteps: nextStepsList
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
return results;
|
|
202
|
+
}
|
|
203
|
+
|
|
@@ -112,7 +112,7 @@ async function emitFlow(flow, objects) {
|
|
|
112
112
|
flowStepName: '',
|
|
113
113
|
mainFileName: `${process}_Main`,
|
|
114
114
|
functionName: process,
|
|
115
|
-
startConfig:
|
|
115
|
+
startConfig: _startConfig(flow)
|
|
116
116
|
};
|
|
117
117
|
const artifacts = needsProcessMain(flow)
|
|
118
118
|
? [
|
|
@@ -319,7 +319,7 @@ async function emitExtTopicStep({ flow, step, flowTag, stepName }) {
|
|
|
319
319
|
const artifacts = [
|
|
320
320
|
{
|
|
321
321
|
path: `${source}/${mainFileName}.js`,
|
|
322
|
-
content: await renderStepMain(functionName)
|
|
322
|
+
content: await renderStepMain(functionName, _startConfig(flow))
|
|
323
323
|
}
|
|
324
324
|
];
|
|
325
325
|
const functions = [];
|
|
@@ -373,7 +373,7 @@ async function emitDsqStep({ flow, step, flowTag, stepName }) {
|
|
|
373
373
|
if (!stepEvents.includes('extTopic')) {
|
|
374
374
|
artifacts.push({
|
|
375
375
|
path: `${source}/${mainFileName}.js`,
|
|
376
|
-
content: await renderStepMain(functionName)
|
|
376
|
+
content: await renderStepMain(functionName, startConfig)
|
|
377
377
|
});
|
|
378
378
|
}
|
|
379
379
|
const functions = [];
|
|
@@ -418,7 +418,7 @@ async function emitOwnTopicRoot(flow, objects) {
|
|
|
418
418
|
flowTag: flow.flowTag,
|
|
419
419
|
flowStepName: '',
|
|
420
420
|
upperCaseFlowTag: tag,
|
|
421
|
-
startConfig:
|
|
421
|
+
startConfig: _startConfig(flow)
|
|
422
422
|
};
|
|
423
423
|
return {
|
|
424
424
|
artifacts: [
|
|
@@ -638,8 +638,20 @@ function _s3HandlerData({ action, flow, functionName, mainFileName, handler }) {
|
|
|
638
638
|
return { functionName, handlerType: handler };
|
|
639
639
|
}
|
|
640
640
|
|
|
641
|
-
function
|
|
642
|
-
const
|
|
641
|
+
function _startConfig(flow) {
|
|
642
|
+
const steps = flow.flowSteps ?? [];
|
|
643
|
+
const start =
|
|
644
|
+
steps.find(
|
|
645
|
+
(s) =>
|
|
646
|
+
typeof s?.stepName === 'string' &&
|
|
647
|
+
s.stepName.toLowerCase() === 'inprocess'
|
|
648
|
+
) ??
|
|
649
|
+
steps.find(
|
|
650
|
+
(s) =>
|
|
651
|
+
typeof s?.stepName === 'string' &&
|
|
652
|
+
s.stepName.toLowerCase() === 'start'
|
|
653
|
+
) ??
|
|
654
|
+
steps[0];
|
|
643
655
|
if (start) {
|
|
644
656
|
return stepConfig(flow, start);
|
|
645
657
|
}
|
|
@@ -657,11 +669,28 @@ function stepConfig(flow, step) {
|
|
|
657
669
|
};
|
|
658
670
|
}
|
|
659
671
|
|
|
660
|
-
function mapFields(
|
|
661
|
-
return
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
672
|
+
function mapFields(items = [], definitions = {}) {
|
|
673
|
+
return items.map((item) => {
|
|
674
|
+
if (typeof item === 'string') {
|
|
675
|
+
const def = definitions?.[item] ?? {};
|
|
676
|
+
return {
|
|
677
|
+
propertyName: item,
|
|
678
|
+
required: def.required ?? false,
|
|
679
|
+
...def
|
|
680
|
+
};
|
|
681
|
+
}
|
|
682
|
+
if (typeof item === 'object' && item !== null) {
|
|
683
|
+
const name = item.key ?? item.propertyName;
|
|
684
|
+
const def = definitions?.[name] ?? {};
|
|
685
|
+
return {
|
|
686
|
+
propertyName: name,
|
|
687
|
+
required: item.required ?? def.required ?? false,
|
|
688
|
+
...def,
|
|
689
|
+
...item
|
|
690
|
+
};
|
|
691
|
+
}
|
|
692
|
+
return item;
|
|
693
|
+
});
|
|
665
694
|
}
|
|
666
695
|
|
|
667
696
|
function isS3Only(flow) {
|
|
@@ -674,7 +703,8 @@ async function renderEndpointMain(flow, functionName, objects) {
|
|
|
674
703
|
flowTag: flow.flowTag,
|
|
675
704
|
upperCaseFlowTag: upperFirst(flow.flowTag),
|
|
676
705
|
functionName,
|
|
677
|
-
tableName: storedCacheTableName(flow, objects)
|
|
706
|
+
tableName: storedCacheTableName(flow, objects),
|
|
707
|
+
startConfig: _startConfig(flow)
|
|
678
708
|
});
|
|
679
709
|
}
|
|
680
710
|
|
|
@@ -698,8 +728,8 @@ function storedCacheTableName(flow, objects) {
|
|
|
698
728
|
);
|
|
699
729
|
}
|
|
700
730
|
|
|
701
|
-
async function renderStepMain(functionName) {
|
|
702
|
-
return renderCustom('FlowStep_Main.ejs', { functionName });
|
|
731
|
+
async function renderStepMain(functionName, startConfig = null) {
|
|
732
|
+
return renderCustom('FlowStep_Main.ejs', { functionName, startConfig });
|
|
703
733
|
}
|
|
704
734
|
|
|
705
735
|
function renderMain(functionName) {
|
|
@@ -6,33 +6,38 @@ import callingFlowSharedLib from '@izara_project/izara-core-library-calling-flow
|
|
|
6
6
|
import <%- functionName %> from './<%- functionName %>_Main.js';
|
|
7
7
|
|
|
8
8
|
let perRecordsValidatorSchema = {
|
|
9
|
-
|
|
9
|
+
<%_ if (typeof startConfig !== 'undefined' && startConfig !== null && startConfig.properties && startConfig.properties.length > 0) { _%>
|
|
10
10
|
type: 'object',
|
|
11
11
|
properties: {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
<%_ startConfig.properties.forEach((prop, index) => { _%>
|
|
13
|
+
<%- /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(prop.propertyName) ? prop.propertyName : `'${prop.propertyName}'` %>: {
|
|
14
|
+
type: '<%- prop.type || 'string' %>'<% if (typeof prop.default !== 'undefined') { %>,
|
|
15
|
+
default: <%- typeof prop.default === 'string' ? `'${prop.default.replace(/'/g, "\\'")}'` : JSON.stringify(prop.default) %><% } %>
|
|
16
|
+
}<%- index < startConfig.properties.length - 1 ? ',' : '' %>
|
|
17
|
+
<%_ }) _%>
|
|
16
18
|
},
|
|
17
19
|
required: [<%- startConfig.properties.filter(p => p.required === true).map(p => `'${p.propertyName}'`).join(', ') %>]
|
|
18
|
-
|
|
20
|
+
<%_ } _%>
|
|
19
21
|
};
|
|
20
22
|
|
|
21
|
-
<% if (typeof startConfig !== 'undefined' && startConfig !== null && startConfig.messageAttributes && startConfig.messageAttributes.length > 0) {
|
|
23
|
+
<%_ if (typeof startConfig !== 'undefined' && startConfig !== null && startConfig.messageAttributes && startConfig.messageAttributes.length > 0) { _%>
|
|
22
24
|
let messageAttributeValidatorSchema = {
|
|
23
25
|
type: 'object',
|
|
24
26
|
properties: {
|
|
25
|
-
|
|
27
|
+
<%_ startConfig.messageAttributes.forEach((prop, index) => { _%>
|
|
28
|
+
<%- /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(prop.propertyName) ? prop.propertyName : `'${prop.propertyName}'` %>: {
|
|
26
29
|
type: 'object',
|
|
27
30
|
properties: {
|
|
28
31
|
Type: { type: 'string' },
|
|
29
32
|
Value: { type: '<%- prop.type || 'string' %>' }
|
|
30
33
|
},
|
|
31
34
|
required: ['Type', 'Value']
|
|
32
|
-
}
|
|
33
|
-
|
|
35
|
+
}<%- index < startConfig.messageAttributes.length - 1 ? ',' : '' %>
|
|
36
|
+
<%_ }) _%>
|
|
34
37
|
},
|
|
35
38
|
required: [<%- startConfig.messageAttributes.filter(p => p.required === true).map(p => `'${p.propertyName}'`).join(', ') %>]
|
|
39
|
+
//(<messageAttributeValidatorSchema>)
|
|
40
|
+
//(</messageAttributeValidatorSchema>)
|
|
36
41
|
};
|
|
37
42
|
<% } else { -%>
|
|
38
43
|
let messageAttributeValidatorSchema = null;
|
|
@@ -305,17 +305,22 @@ function _functionSetting(functionName) {
|
|
|
305
305
|
return ` #<#${functionName}FunctionSetting#>\n #<#/${functionName}FunctionSetting#>`;
|
|
306
306
|
}
|
|
307
307
|
|
|
308
|
-
function _sqsFilterPatterns(
|
|
309
|
-
|
|
308
|
+
function _sqsFilterPatterns(
|
|
309
|
+
callingFlowName,
|
|
310
|
+
hookFunctionName = callingFlowName
|
|
311
|
+
) {
|
|
312
|
+
return ` #<#${hookFunctionName}FilterPatterns#>
|
|
313
|
+
filterPatterns:
|
|
310
314
|
- body:
|
|
311
315
|
MessageAttributes:
|
|
312
316
|
callingFlow:
|
|
313
317
|
Value:
|
|
314
|
-
- \${self:custom.iz_resourcePrefix}${
|
|
318
|
+
- \${self:custom.iz_resourcePrefix}${callingFlowName}
|
|
315
319
|
- body:
|
|
316
320
|
MessageAttributes:
|
|
317
321
|
callingFlow:
|
|
318
322
|
Value:
|
|
319
323
|
- exists: false
|
|
324
|
+
#<#/${hookFunctionName}FilterPatterns#>
|
|
320
325
|
`;
|
|
321
326
|
}
|
|
@@ -36,13 +36,17 @@ const { TOPIC_NAME_GENERATE_CODE, PREFIX } = consts;
|
|
|
36
36
|
|
|
37
37
|
export default async function changeRelationshipComplete(
|
|
38
38
|
_izContext,
|
|
39
|
-
|
|
40
|
-
status,
|
|
41
|
-
errorsFound,
|
|
42
|
-
graphServiceTag,
|
|
39
|
+
requestParams,
|
|
43
40
|
passBackProperties = {}
|
|
44
41
|
) {
|
|
45
42
|
try {
|
|
43
|
+
const {
|
|
44
|
+
returnValue,
|
|
45
|
+
status,
|
|
46
|
+
errorsFound,
|
|
47
|
+
graphServiceTag
|
|
48
|
+
} = requestParams;
|
|
49
|
+
|
|
46
50
|
_izContext.logger.debug('Function:ChangeRelationshipComplete', {
|
|
47
51
|
returnValue: returnValue,
|
|
48
52
|
status: status,
|
|
@@ -51,15 +55,6 @@ export default async function changeRelationshipComplete(
|
|
|
51
55
|
passBackProperties: passBackProperties
|
|
52
56
|
});
|
|
53
57
|
|
|
54
|
-
// start create awaitingStepId
|
|
55
|
-
const linkTypeId = createLinkTypeId(
|
|
56
|
-
_izContext,
|
|
57
|
-
returnValue.requestParams.firstObject.objType,
|
|
58
|
-
returnValue.requestParams.secondObject.objType,
|
|
59
|
-
returnValue.requestParams.newRelType,
|
|
60
|
-
returnValue.requestParams.oldRelTypeAndDirection.relationshipDirection
|
|
61
|
-
);
|
|
62
|
-
|
|
63
58
|
let awaitingStepId = asyncFlowSharedLib.createAwaitingStepId(
|
|
64
59
|
returnValue.parentFlowId, // hash id
|
|
65
60
|
PREFIX.changeRel // prefix, use constant further
|
|
@@ -390,15 +390,6 @@ export default async function <%- functionName %>(
|
|
|
390
390
|
return changeRelCompleteMsg;
|
|
391
391
|
}
|
|
392
392
|
|
|
393
|
-
// before create awaitingStepId per graph storageResource
|
|
394
|
-
const linkTypeId = createLinkTypeId(
|
|
395
|
-
_izContext,
|
|
396
|
-
firstObject.objType,
|
|
397
|
-
secondObject.objType,
|
|
398
|
-
newRelType,
|
|
399
|
-
oldRelTypeAndDirection.relationshipDirection
|
|
400
|
-
);
|
|
401
|
-
|
|
402
393
|
let usedGraphServiceTag = []; // collect used graph serviceTag, use to check duplicate graph serviceTag across graph serverTag
|
|
403
394
|
let targetGraphStorageResources = []; // collect used graph storageResources, filtered duplicate graphServiceTag from graphServerTag out
|
|
404
395
|
let awaitingStepIds = [];
|
|
@@ -412,12 +403,12 @@ export default async function <%- functionName %>(
|
|
|
412
403
|
targetGraphStorageResources.push(targetStorageResource);
|
|
413
404
|
|
|
414
405
|
// awaitingStepId per graphServiceTag
|
|
415
|
-
awaitingStepIds.push(
|
|
416
|
-
asyncFlowSharedLib.createAwaitingStepId(
|
|
406
|
+
awaitingStepIds.push({
|
|
407
|
+
awaitingStepId: asyncFlowSharedLib.createAwaitingStepId(
|
|
417
408
|
parentFlowId, // hash id
|
|
418
409
|
PREFIX.changeRel // prefix, use constant further
|
|
419
410
|
)
|
|
420
|
-
);
|
|
411
|
+
});
|
|
421
412
|
}
|
|
422
413
|
}
|
|
423
414
|
|
|
@@ -426,11 +417,11 @@ export default async function <%- functionName %>(
|
|
|
426
417
|
await asyncFlowSharedLib.createAwaitingMultipleSteps(
|
|
427
418
|
_izContext,
|
|
428
419
|
asyncFlowSharedLib.createPendingStepId(
|
|
429
|
-
// pendingStepId
|
|
430
420
|
_izContext.uniqueRequestId, // hash id
|
|
431
421
|
PREFIX.changeRel // prefix, use constant further
|
|
432
422
|
),
|
|
433
|
-
awaitingStepIds
|
|
423
|
+
awaitingStepIds,
|
|
424
|
+
{}
|
|
434
425
|
);
|
|
435
426
|
|
|
436
427
|
// prepare message body
|
|
@@ -36,13 +36,17 @@ const { TOPIC_NAME_GENERATE_CODE, PREFIX } = consts;
|
|
|
36
36
|
|
|
37
37
|
export default async function createRelationshipComplete(
|
|
38
38
|
_izContext,
|
|
39
|
-
|
|
40
|
-
status,
|
|
41
|
-
errorsFound,
|
|
42
|
-
graphServiceTag,
|
|
39
|
+
requestParams,
|
|
43
40
|
passBackProperties = {}
|
|
44
41
|
) {
|
|
45
42
|
try {
|
|
43
|
+
const {
|
|
44
|
+
returnValue,
|
|
45
|
+
status,
|
|
46
|
+
errorsFound,
|
|
47
|
+
graphServiceTag
|
|
48
|
+
} = requestParams;
|
|
49
|
+
|
|
46
50
|
_izContext.logger.debug('Function:createRelationshipComplete', {
|
|
47
51
|
returnValue: returnValue,
|
|
48
52
|
status: status,
|
|
@@ -51,15 +55,6 @@ export default async function createRelationshipComplete(
|
|
|
51
55
|
passBackProperties: passBackProperties
|
|
52
56
|
});
|
|
53
57
|
|
|
54
|
-
// start create awaitingStepId
|
|
55
|
-
const linkTypeId = createLinkTypeId(
|
|
56
|
-
_izContext,
|
|
57
|
-
returnValue.requestParams.firstObject.objType,
|
|
58
|
-
returnValue.requestParams.secondObject.objType,
|
|
59
|
-
returnValue.requestParams.relType,
|
|
60
|
-
returnValue.requestParams.relationshipDirection
|
|
61
|
-
);
|
|
62
|
-
|
|
63
58
|
let awaitingStepId = asyncFlowSharedLib.createAwaitingStepId(
|
|
64
59
|
returnValue.parentFlowId, // hash id
|
|
65
60
|
PREFIX.createRel // prefix, use constant further
|