@izara_project/izara-core-generate-service-code 1.0.41 → 1.0.43
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 +1 -1
- package/src/generateCode/generateFlowStepWithPlugIn/firstFlowStep/mainFunction/data.js +1 -16
- package/src/generateCode/generateFlowStepWithPlugIn/firstFlowStep/mainFunction/template.ejs +1 -1
- package/src/generateCode/generateFlowStepWithPlugIn/firstFlowStep/mainFunction/templateByConfig/awaitingSteps.ejs +0 -4
- package/src/generateCode/generateFlowStepWithPlugIn/firstFlowStep/queueNtopic/data.js +1 -1
- package/src/generateCode/generateFlowStepWithPlugIn/firstFlowStep/queueNtopic/dsqTemplate.ejs +43 -0
- package/src/generateCode/generateFlowStepWithPlugIn/firstFlowStep/queueNtopic/sqsTemplate.ejs +8 -8
- package/src/generateCode/generateFlowStepWithPlugIn/index.js +11 -13
- package/src/generateCode/generateSchema/actionEndpointCompleteComponent/create/mainFunction/template.ejs +2 -0
- package/src/generateCode/generateSchema/actionEndpointComponent/mainFunction/create/main/template.ejs +49 -21
- package/src/libs/Libs.js +12 -15
package/package.json
CHANGED
|
@@ -31,7 +31,7 @@ const templateSendPlugin = path.join(__dirname, './templateByConfig/templateSend
|
|
|
31
31
|
const templateAwaitingStep = path.join(__dirname, './templateByConfig/awaitingSteps.ejs');
|
|
32
32
|
|
|
33
33
|
async function data(_izContext, data, appPath) {
|
|
34
|
-
|
|
34
|
+
console.log("dataInMain", data)
|
|
35
35
|
const [mainFlow] = await getLocalOrS3FlowSchema(
|
|
36
36
|
_izContext,
|
|
37
37
|
{
|
|
@@ -42,25 +42,10 @@ async function data(_izContext, data, appPath) {
|
|
|
42
42
|
appPath, './src/schemas')
|
|
43
43
|
);
|
|
44
44
|
|
|
45
|
-
const [childFlow] = await getLocalOrS3FlowSchema(
|
|
46
|
-
_izContext,
|
|
47
|
-
data.childFlow,
|
|
48
|
-
path.join(
|
|
49
|
-
appPath, './src/schemas')
|
|
50
|
-
);
|
|
51
|
-
|
|
52
45
|
if (mainFlow.hasOwnProperty('objType')) {
|
|
53
46
|
data['mainObjType'] = mainFlow.objType;
|
|
54
47
|
};
|
|
55
48
|
|
|
56
|
-
if (!childFlow) {
|
|
57
|
-
throw new NoRetryError(`can't get ${childFlow} from s3 or local`);
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
if (childFlow && childFlow.hasOwnProperty('objType')) {
|
|
61
|
-
data['childObjType'] = childFlow.objType;
|
|
62
|
-
};
|
|
63
|
-
|
|
64
49
|
|
|
65
50
|
return {
|
|
66
51
|
templatePath: templatePath,
|
|
@@ -58,7 +58,7 @@ export default async function <%- functionName %>(
|
|
|
58
58
|
//(<hookCode>)
|
|
59
59
|
|
|
60
60
|
<% if (handleLogic === 'awaitingMultipleSteps') { %>
|
|
61
|
-
<%- include(templateAwaitingStep, { childFlow, mainObjType
|
|
61
|
+
<%- include(templateAwaitingStep, { childFlow, mainObjType }) %>
|
|
62
62
|
<% } %>
|
|
63
63
|
<% if (havePlugIn) { -%>
|
|
64
64
|
<%- include(templateSendPlugin, {havePlugIn: havePlugIn, invokeType: invokeType, targetUrl: targetUrl}) %>
|
|
@@ -52,10 +52,6 @@ await asyncFlowSharedLib.createAwaitingMultipleStepsWithAdditionalAttributes(
|
|
|
52
52
|
)
|
|
53
53
|
);
|
|
54
54
|
|
|
55
|
-
await sns.publishAsync(_izContext, {
|
|
56
|
-
Message: JSON.stringify(messageObject),
|
|
57
|
-
TopicArn: await snsSharedLib.snsTopicArnByFlowSchema(_izContext, "<%- childFlow.flowTag %>_In", "<%- childFlow.serviceTag %>")
|
|
58
|
-
});
|
|
59
55
|
//(</afterCreateAwatingSteps>)
|
|
60
56
|
|
|
61
57
|
<%_ function firstLetterUpperCase(text) {
|
|
@@ -26,7 +26,7 @@ import utils from '#libs/Utils.js';
|
|
|
26
26
|
const { firstLetterUpperCase: upperCase } = utils;
|
|
27
27
|
const { SOURCE_PATH, SAVE_FILE_NAME, HANDLER } = consts;
|
|
28
28
|
const templatePathByHandler = {
|
|
29
|
-
[HANDLER.hdrDsq]: path.join(__dirname, './
|
|
29
|
+
[HANDLER.hdrDsq]: path.join(__dirname, './dsqTemplate.ejs'),
|
|
30
30
|
[HANDLER.hdrSqs]: path.join(__dirname, './snsTemplate.ejs'),
|
|
31
31
|
queueNoTopic: path.join(__dirname, './sqsTemplate.ejs')
|
|
32
32
|
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
#------- queue ---------
|
|
2
|
+
<%- queueName %>HdrDsq:
|
|
3
|
+
Type: "AWS::SQS::Queue"
|
|
4
|
+
Properties:
|
|
5
|
+
QueueName: ${self:custom.iz_resourcePrefix}<%- queueName %>HdrDsq
|
|
6
|
+
RedrivePolicy:
|
|
7
|
+
deadLetterTargetArn: #!GetAtt
|
|
8
|
+
Fn::GetAtt:
|
|
9
|
+
- <%- queueName %>HdrDsqDLQ
|
|
10
|
+
- Arn
|
|
11
|
+
maxReceiveCount: 3
|
|
12
|
+
VisibilityTimeout: 120
|
|
13
|
+
|
|
14
|
+
<%- queueName %>HdrDsqDLQ:
|
|
15
|
+
Type: AWS::SQS::Queue
|
|
16
|
+
Properties:
|
|
17
|
+
QueueName: ${self:custom.iz_resourcePrefix}<%- queueName %>HdrDsqDLQ
|
|
18
|
+
|
|
19
|
+
<%- queueName %>HdrDsqPolicy:
|
|
20
|
+
Type: AWS::SQS::QueuePolicy
|
|
21
|
+
Properties:
|
|
22
|
+
PolicyDocument:
|
|
23
|
+
Version: "2012-10-17"
|
|
24
|
+
Statement:
|
|
25
|
+
- Sid: "allow-sns-messages"
|
|
26
|
+
Effect: Allow
|
|
27
|
+
Principal: "*"
|
|
28
|
+
Resource: #!GetAtt
|
|
29
|
+
Fn::GetAtt:
|
|
30
|
+
- <%- queueName %>HdrDsq
|
|
31
|
+
- Arn
|
|
32
|
+
Action: "SQS:SendMessage"
|
|
33
|
+
Queues:
|
|
34
|
+
- Ref: <%- queueName %>HdrDsq
|
|
35
|
+
#<#<%- firstLetterUpperCase(queueName) %>QueueSetting#>
|
|
36
|
+
#<#/<%- firstLetterUpperCase(queueName) %>QueueSetting#>
|
|
37
|
+
|
|
38
|
+
<%_ function firstLetterUpperCase(text){
|
|
39
|
+
return text.charAt(0).toUpperCase() + text.slice(1)
|
|
40
|
+
} _%>
|
|
41
|
+
<%_ function firstLetterLowerCase(str) {
|
|
42
|
+
return str.charAt(0).toLowerCase() + str.slice(1)
|
|
43
|
+
} _%>
|
package/src/generateCode/generateFlowStepWithPlugIn/firstFlowStep/queueNtopic/sqsTemplate.ejs
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
#------- queue ---------
|
|
2
|
-
<%- queueName %>
|
|
2
|
+
<%- queueName %>HdrSqs:
|
|
3
3
|
Type: "AWS::SQS::Queue"
|
|
4
4
|
Properties:
|
|
5
|
-
QueueName: ${self:custom.iz_resourcePrefix}<%- queueName %>
|
|
5
|
+
QueueName: ${self:custom.iz_resourcePrefix}<%- queueName %>HdrSqs
|
|
6
6
|
RedrivePolicy:
|
|
7
7
|
deadLetterTargetArn: #!GetAtt
|
|
8
8
|
Fn::GetAtt:
|
|
9
|
-
- <%- queueName %>
|
|
9
|
+
- <%- queueName %>HdrSqsDLQ
|
|
10
10
|
- Arn
|
|
11
11
|
maxReceiveCount: 3
|
|
12
12
|
VisibilityTimeout: 120
|
|
13
13
|
|
|
14
|
-
<%- queueName %>
|
|
14
|
+
<%- queueName %>HdrSqsDLQ:
|
|
15
15
|
Type: AWS::SQS::Queue
|
|
16
16
|
Properties:
|
|
17
|
-
QueueName: ${self:custom.iz_resourcePrefix}<%- queueName %>
|
|
17
|
+
QueueName: ${self:custom.iz_resourcePrefix}<%- queueName %>HdrSqsDLQ
|
|
18
18
|
|
|
19
|
-
<%- queueName %>
|
|
19
|
+
<%- queueName %>HdrSqsPolicy:
|
|
20
20
|
Type: AWS::SQS::QueuePolicy
|
|
21
21
|
Properties:
|
|
22
22
|
PolicyDocument:
|
|
@@ -27,11 +27,11 @@
|
|
|
27
27
|
Principal: "*"
|
|
28
28
|
Resource: #!GetAtt
|
|
29
29
|
Fn::GetAtt:
|
|
30
|
-
- <%- queueName %>
|
|
30
|
+
- <%- queueName %>HdrSqs
|
|
31
31
|
- Arn
|
|
32
32
|
Action: "SQS:SendMessage"
|
|
33
33
|
Queues:
|
|
34
|
-
- Ref: <%- queueName %>
|
|
34
|
+
- Ref: <%- queueName %>HdrSqs
|
|
35
35
|
#<#<%- firstLetterUpperCase(queueName) %>QueueSetting#>
|
|
36
36
|
#<#/<%- firstLetterUpperCase(queueName) %>QueueSetting#>
|
|
37
37
|
|
|
@@ -129,7 +129,7 @@ async function generatePlunIg(
|
|
|
129
129
|
upperCase(flowSchema.flowTag) +
|
|
130
130
|
upperCase(flowStepName) +
|
|
131
131
|
upperCase(data.handlerType)),
|
|
132
|
-
queueName: upperCase(flowSchema.flowTag) + upperCase(flowStepName),
|
|
132
|
+
queueName: upperCase(flowSchema.flowTag) + upperCase(flowStepName) + upperCase(data.handlerType),
|
|
133
133
|
});
|
|
134
134
|
|
|
135
135
|
|
|
@@ -137,10 +137,6 @@ async function generatePlunIg(
|
|
|
137
137
|
if (flowStepConfig.plugInHooks?.length) {
|
|
138
138
|
for (let i = 0; i < flowStepConfig.plugInHooks.length; i++) {
|
|
139
139
|
if (i === 0) {
|
|
140
|
-
if (flowStepConfig.hasOwnProperty("settings")) {
|
|
141
|
-
data["handleLogic"] = flowStepConfig.settings.handleLogic;
|
|
142
|
-
data["childFlow"] = flowStepConfig.settings.flowType;
|
|
143
|
-
};
|
|
144
140
|
const firstResults = await buildFirstPluginHookResources(
|
|
145
141
|
_izContext,
|
|
146
142
|
data,
|
|
@@ -159,14 +155,10 @@ async function generatePlunIg(
|
|
|
159
155
|
allCreateSourceParams.push(...afterResults);
|
|
160
156
|
}
|
|
161
157
|
} else {
|
|
162
|
-
if (flowStepConfig.hasOwnProperty("settings")) {
|
|
163
|
-
data["handleLogic"] = flowStepConfig.settings.handleLogic;
|
|
164
|
-
data["childFlow"] = flowStepConfig.settings.flowType;
|
|
165
|
-
};
|
|
166
|
-
|
|
167
158
|
const noHookResults = await buildNoPluginHookResources(
|
|
168
159
|
_izContext,
|
|
169
160
|
data,
|
|
161
|
+
flowStepConfig,
|
|
170
162
|
appPath
|
|
171
163
|
);
|
|
172
164
|
allCreateSourceParams.push(...noHookResults);
|
|
@@ -224,10 +216,9 @@ async function generatePlunIg(
|
|
|
224
216
|
export default generatePlunIg;
|
|
225
217
|
|
|
226
218
|
|
|
227
|
-
async function buildNoPluginHookResources(_izContext, data, appPath) {
|
|
219
|
+
async function buildNoPluginHookResources(_izContext, data, flowStepConfig, appPath) {
|
|
228
220
|
const results = [];
|
|
229
221
|
|
|
230
|
-
|
|
231
222
|
const yamlRes = await yamlFlowStep(
|
|
232
223
|
_izContext,
|
|
233
224
|
data,
|
|
@@ -253,7 +244,13 @@ async function buildNoPluginHookResources(_izContext, data, appPath) {
|
|
|
253
244
|
|
|
254
245
|
const mainRes = await mainFunctionFlowStep(
|
|
255
246
|
_izContext,
|
|
256
|
-
{
|
|
247
|
+
{
|
|
248
|
+
...data,
|
|
249
|
+
havePlugIn: false,
|
|
250
|
+
handleLogic: flowStepConfig.settings?.handleLogic || 'none'
|
|
251
|
+
},
|
|
252
|
+
appPath
|
|
253
|
+
);
|
|
257
254
|
|
|
258
255
|
results.push(mainRes,
|
|
259
256
|
// snsOutRes,
|
|
@@ -322,6 +319,7 @@ async function buildFirstPluginHookResources(_izContext, data, flowStepConfig, a
|
|
|
322
319
|
havePlugIn: true,
|
|
323
320
|
invokeType: targetPlugIn.invocationType,
|
|
324
321
|
targetUrl,
|
|
322
|
+
handleLogic: flowStepConfig.settings?.handleLogic || 'none'
|
|
325
323
|
};
|
|
326
324
|
}
|
|
327
325
|
}
|
|
@@ -256,6 +256,7 @@ export default async function createObjectComplete(
|
|
|
256
256
|
|
|
257
257
|
await Promise.all(
|
|
258
258
|
recordAwaitingStep.listOfRecords.map(async (listOfRecords) => {
|
|
259
|
+
if (status === 'complete') {
|
|
259
260
|
Object.entries(listOfRecords).map(async ([tableName, record]) => {
|
|
260
261
|
await dynamodbSharedLib.putItem(
|
|
261
262
|
_izContext,
|
|
@@ -269,6 +270,7 @@ export default async function createObjectComplete(
|
|
|
269
270
|
}
|
|
270
271
|
);
|
|
271
272
|
})
|
|
273
|
+
}
|
|
272
274
|
}))
|
|
273
275
|
|
|
274
276
|
const messageObject = buildMessageObject(
|
|
@@ -138,8 +138,6 @@ export async function createMainLogical(
|
|
|
138
138
|
|
|
139
139
|
// ── DynamoDB ──────────────────────────────────────────────────────────
|
|
140
140
|
if (createDataDetail.storageType === consts.STORAGE_TYPES.dynamoDB) {
|
|
141
|
-
//(<beforeCreateRecordDynamo>)
|
|
142
|
-
//(</beforeCreateRecordDynamo>)
|
|
143
141
|
_izContext.logger.debug('::::::DynamoDB::::::', { storageTag, objInstanceFull });
|
|
144
142
|
|
|
145
143
|
if (parentObject && createDataDetail.tableName.includes(firstLetterUpperCase(`${parentObject.objectType}Records`))) {
|
|
@@ -152,25 +150,45 @@ export async function createMainLogical(
|
|
|
152
150
|
_izContext.logger.debug('objInstanceFull before create item in dynamoDB', objInstanceFullForDynamoDb);
|
|
153
151
|
|
|
154
152
|
const identifiersForCreateData = await dynamoDbIdentifiersByStorageResource(
|
|
155
|
-
_izContext,
|
|
153
|
+
_izContext,
|
|
154
|
+
objectSchema,
|
|
155
|
+
createDataDetails,
|
|
156
|
+
objInstanceFullForDynamoDb.identifiers
|
|
156
157
|
);
|
|
157
158
|
_izContext.logger.debug('identifiersForCreateData', identifiersForCreateData);
|
|
158
159
|
|
|
159
|
-
//
|
|
160
|
-
//
|
|
161
|
-
// await dynamodbSharedLib.tableName(_izContext, createDataDetail.tableName, createDataDetail.serviceTag),
|
|
162
|
-
// { ...identifiersForCreateData, ...objInstanceFullForDynamoDb.fields }
|
|
163
|
-
// );
|
|
160
|
+
//(<beforeCreateRecordDynamo>)
|
|
161
|
+
//(</beforeCreateRecordDynamo>)
|
|
164
162
|
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
163
|
+
if (Object.values(createDataDetails).some(
|
|
164
|
+
createDataDetail => createDataDetail.storageType === consts.STORAGE_TYPES.graph)) {
|
|
165
|
+
_izContext.logger.debug('must process graph first');
|
|
166
|
+
listOfRecords.push({
|
|
167
|
+
[createDataDetail.tableName]: {
|
|
168
|
+
serviceTag: createDataDetail.serviceTag,
|
|
169
|
+
objInstanceFull: {
|
|
170
|
+
identifiers: identifiersForCreateData,
|
|
171
|
+
fields: objInstanceFullForDynamoDb.fields
|
|
172
|
+
}
|
|
171
173
|
}
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
+
})
|
|
175
|
+
} else {
|
|
176
|
+
_izContext.logger.debug('can process record dynamo')
|
|
177
|
+
await dynamodbSharedLib.putItem(
|
|
178
|
+
_izContext,
|
|
179
|
+
dynamodbSharedLib.tableName(_izContext,
|
|
180
|
+
createDataDetail.tableName,
|
|
181
|
+
createDataDetail.serviceTag
|
|
182
|
+
),
|
|
183
|
+
{
|
|
184
|
+
...identifiersForCreateData,
|
|
185
|
+
...objInstanceFullForDynamoDb.fields
|
|
186
|
+
}
|
|
187
|
+
);
|
|
188
|
+
|
|
189
|
+
objInstanceFullForDynamoDb.fields = {}
|
|
190
|
+
}
|
|
191
|
+
|
|
174
192
|
//(<afterCreateRecordDynamo>)
|
|
175
193
|
//(</afterCreateRecordDynamo>)
|
|
176
194
|
|
|
@@ -338,10 +356,17 @@ export async function createMainLogical(
|
|
|
338
356
|
|
|
339
357
|
// ── DynamoDB-only complete path ───────────────────────────────────────────
|
|
340
358
|
if (allAwaitingStepsId.length === 0 && listOfObjectForCreates.length === 0) {
|
|
341
|
-
const outMessage =
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
359
|
+
const outMessage =
|
|
360
|
+
callingFlowSharedLib.addPassBackPropertiesToSnsResponseMessageObject(
|
|
361
|
+
callingFlowConfig,
|
|
362
|
+
{
|
|
363
|
+
objType: objType,
|
|
364
|
+
objInstanceFull: {
|
|
365
|
+
identifiers: objInstanceFullForDynamoDb.identifiers,
|
|
366
|
+
fields: objInstanceFullForDynamoDb.fields
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
);
|
|
345
370
|
|
|
346
371
|
if (callingFlowConfig[callingFlowSharedLib.consts.CALLINGFLOW_PROPERTYNAME]) {
|
|
347
372
|
_izContext.logger.debug('HAVE CallingFlow');
|
|
@@ -358,7 +383,10 @@ export async function createMainLogical(
|
|
|
358
383
|
|
|
359
384
|
return {
|
|
360
385
|
objType,
|
|
361
|
-
objInstanceFull:
|
|
386
|
+
objInstanceFull: {
|
|
387
|
+
identifiers: objInstanceFullForDynamoDb.identifiers,
|
|
388
|
+
fields: objInstanceFullForDynamoDb.fields
|
|
389
|
+
},
|
|
362
390
|
relationships: requestParams.relationships || [],
|
|
363
391
|
status: 'complete',
|
|
364
392
|
errorsFound
|
package/src/libs/Libs.js
CHANGED
|
@@ -120,32 +120,29 @@ function externalResourceName(resourceClass, resourceName, serviceTag) {
|
|
|
120
120
|
}
|
|
121
121
|
|
|
122
122
|
function externalResourceYaml(resourceClass, resourceName, serviceTag) {
|
|
123
|
-
|
|
124
|
-
// serviceTag = '${self:custom.iz_resourcePrefix}';
|
|
125
|
-
// } else {
|
|
126
|
-
// serviceTag = serviceTag + '${self:custom.iz_stage}';
|
|
127
|
-
// }
|
|
123
|
+
|
|
128
124
|
return {
|
|
129
125
|
[RESOURCE_CLASSES.dynamoDbTable]:
|
|
130
126
|
'arn:aws:dynamodb:${self:custom.iz_region}:${self:custom.iz_accountId}:table/' +
|
|
131
127
|
serviceTag ?
|
|
132
|
-
'${self:custom.iz_resourcePrefix}'
|
|
133
|
-
|
|
134
|
-
// `${serviceTag}` +
|
|
135
|
-
// `${resourceName}`,
|
|
128
|
+
'${self:custom.iz_resourcePrefix}' + resourceName :
|
|
129
|
+
serviceTag + '${self:custom.iz_stage}' + resourceName,
|
|
130
|
+
// `${ serviceTag } ` +
|
|
131
|
+
// `${ resourceName } `,
|
|
136
132
|
[RESOURCE_CLASSES.lambda]:
|
|
137
|
-
'arn:aws:lambda:${self:custom.iz_region}:${self:custom.iz_accountId}:function:' +
|
|
133
|
+
'arn:aws:lambda:${self: custom.iz_region}:${self:custom.iz_accountId}:function:' +
|
|
138
134
|
serviceTag ?
|
|
139
|
-
'${self:custom.iz_resourcePrefix}'
|
|
140
|
-
|
|
135
|
+
'${self:custom.iz_resourcePrefix}' + resourceName :
|
|
136
|
+
serviceTag + '${self:custom.iz_stage}' + resourceName,
|
|
141
137
|
[RESOURCE_CLASSES.sns]:
|
|
142
138
|
'arn:aws:sns:${self:custom.iz_region}:${self:custom.iz_accountId}:' +
|
|
143
|
-
|
|
139
|
+
serviceTag ? '${self:custom.iz_serviceTag}_${self:custom.iz_stage}_' + resourceName :
|
|
140
|
+
serviceTag + '_${self:custom.iz_stage}_' + resourceName,
|
|
144
141
|
[RESOURCE_CLASSES.sqs]:
|
|
145
142
|
'arn:aws:sqs:${self:custom.iz_region}:${self:custom.iz_accountId}:' +
|
|
146
143
|
serviceTag ?
|
|
147
|
-
'${self:custom.iz_resourcePrefix}'
|
|
148
|
-
|
|
144
|
+
'${self:custom.iz_resourcePrefix}' + resourceName :
|
|
145
|
+
serviceTag + '${self:custom.iz_stage}' + resourceName,
|
|
149
146
|
}[resourceClass];
|
|
150
147
|
}
|
|
151
148
|
|