@izara_project/izara-market-library-service-schemas 1.0.17 → 1.0.18
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 +4 -4
- package/src/GenerateCodeLibs/src/GenerateCodeLibs.js +24 -0
- package/src/TemplateManager/src/FindData/FindDataYaml/data.js +0 -9
- package/src/TemplateManager/src/GenerateCode.js +16 -5
- package/src/TemplateManager/src/OutPerActionComplete/OutUpdateComplete/mainFunction/template.ejs +1 -1
- package/src/TemplateManager/src/PerActionEndpoint/Handler/HdrDsq/template.ejs +2 -2
- package/src/TemplateManager/src/PerActionEndpoint/Handler/HdrSqs/template.ejs +2 -2
- package/src/TemplateManager/src/PerActionEndpoint/MainFunction/Create/template.ejs +41 -29
- package/src/TemplateManager/src/PerActionEndpoint/MainFunction/Update/template.ejs +28 -0
- package/src/TemplateManager/src/RelationshipPerAction/CreateRelationship/createRelationshipComplete/mainFunction/template.ejs +1 -1
- package/src/TemplateManager/src/RelationshipPerAction/DeleteRelationship/DeleteRelationshipComplete/mainFunction/template.ejs +1 -1
- package/src/TemplateManager/src/RelationshipPerAction/UpdateRelationshipSchema/updateRalationshipComplete/mainFunction/template.ejs +1 -1
- package/src/TemplateManager/src/ResourceYaml/dynamodb/defaultDynamoDbTable.js +15 -0
- package/src/TemplateManager/src/externalService/LambdaRole/data.js +7 -20
- package/src/TemplateManager/src/externalService/SnsTopicSubscriotions/data.js +1 -1
- package/src/TemplateManager/src/flowTag/webSocket/webSocketComplete/functionYaml/data.js +100 -0
- package/src/TemplateManager/src/flowTag/webSocket/webSocketComplete/functionYaml/template.ejs +27 -0
- package/src/TemplateManager/src/flowTag/webSocket/webSocketComplete/handler/data.js +58 -0
- package/src/TemplateManager/src/flowTag/webSocket/webSocketComplete/handler/template.ejs +103 -0
- package/src/TemplateManager/src/flowTag/webSocket/webSocketComplete/mainFunction/data.js +56 -0
- package/src/TemplateManager/src/flowTag/webSocket/webSocketComplete/mainFunction/template.ejs +180 -0
- package/src/TemplateManager/src/flowTag/webSocket/webSocketComplete/sns-sqs/data.js +70 -0
- package/src/TemplateManager/src/flowTag/webSocket/webSocketComplete/sns-sqs/template.ejs +43 -0
- package/src/TemplateManager/src/flowTag/webSocket/webSocketConnect/functionYaml/data.js +22 -5
- package/src/TemplateManager/src/flowTag/webSocket/webSocketConnect/functionYaml/template.ejs +22 -3
- package/src/TemplateManager/src/flowTag/webSocket/webSocketConnect/handler/data.js +3 -3
- package/src/TemplateManager/src/flowTag/webSocket/webSocketConnect/handler/template.ejs +19 -14
- package/src/TemplateManager/src/flowTag/webSocket/websocketHandler/functionYaml/data.js +32 -8
- package/src/TemplateManager/src/flowTag/webSocket/websocketHandler/functionYaml/template.ejs +5 -7
- package/src/TemplateManager/src/flowTag/webSocket/websocketHandler/handler/data.js +59 -0
- package/src/TemplateManager/src/flowTag/webSocket/websocketHandler/handler/template.ejs +130 -0
- package/src/TemplateManager/src/flowTag/webSocket/websocketHandler/{lambda → mainFunction}/data.js +5 -3
- package/src/TemplateManager/src/flowTag/webSocket/websocketHandler/mainFunction/template.ejs +133 -0
- package/src/TemplateManager/src/libs/Consts.js +5 -2
- package/src/TemplateManager/src/flowTag/webSocket/websocketHandler/lambda/template.ejs +0 -131
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@izara_project/izara-market-library-service-schemas",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.18",
|
|
4
4
|
"description": "Schemas for Izara Market project",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -21,9 +21,9 @@
|
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
23
|
"@izara_project/izara-core-library-core": "^1.0.14",
|
|
24
|
-
"@izara_project/izara-core-library-external-request": "^1.0.
|
|
25
|
-
"@izara_project/izara-core-library-service-schemas": "^1.0.
|
|
26
|
-
"@izara_project/izara-shared": "^1.0.
|
|
24
|
+
"@izara_project/izara-core-library-external-request": "^1.0.17",
|
|
25
|
+
"@izara_project/izara-core-library-service-schemas": "^1.0.35",
|
|
26
|
+
"@izara_project/izara-shared": "^1.0.116",
|
|
27
27
|
"ejs": "^3.1.10",
|
|
28
28
|
"js-beautify": "^1.15.1",
|
|
29
29
|
"lodash": "^4.17.21",
|
|
@@ -162,6 +162,30 @@ async function validateSchemaPerRecord(
|
|
|
162
162
|
|
|
163
163
|
}
|
|
164
164
|
|
|
165
|
+
/**
|
|
166
|
+
* use to create validation for initialize request
|
|
167
|
+
*
|
|
168
|
+
* @param {object} _izContext
|
|
169
|
+
* @param {object} flowType
|
|
170
|
+
* @param {object} flowType.flowTag
|
|
171
|
+
* @param {object} flowType.serviceTag
|
|
172
|
+
* @returns {object}
|
|
173
|
+
*/
|
|
174
|
+
|
|
175
|
+
async function validationForWebSocket(
|
|
176
|
+
_izContext,
|
|
177
|
+
flowType
|
|
178
|
+
) {
|
|
179
|
+
_izContext.logger.debug("validator schema for flowTag", {
|
|
180
|
+
flowType
|
|
181
|
+
})
|
|
182
|
+
let flowSchema = await getObjectSchema.getFlowSchemaS3(_izContext, flowType)
|
|
183
|
+
|
|
184
|
+
let validatorSchemaForFlowSchema = flowSchema.initializeRequest.initializeRequestProperties
|
|
185
|
+
_izContext.logger.debug("validatorSchemaForFlowSchema:", validatorSchemaForFlowSchema)
|
|
186
|
+
|
|
187
|
+
|
|
188
|
+
}
|
|
165
189
|
// /**
|
|
166
190
|
// * use to validate record for Lambda handler hdrSqs/hdrDsq
|
|
167
191
|
// * Note!: cannot throw error when use this function outside recordHandler
|
|
@@ -139,15 +139,6 @@ async function data(_izContext, objectSchemas, srcPath) {
|
|
|
139
139
|
);
|
|
140
140
|
}
|
|
141
141
|
|
|
142
|
-
if (graphForGetNode.length) {
|
|
143
|
-
additionalResourcePermission.push(
|
|
144
|
-
createIamRole(
|
|
145
|
-
{ [RESOURCE_CLASSES.lambda]: ["InvokeFunction"] },
|
|
146
|
-
graphForGetNode
|
|
147
|
-
)
|
|
148
|
-
);
|
|
149
|
-
}
|
|
150
|
-
|
|
151
142
|
additionalResourcePermission.push(
|
|
152
143
|
createIamRole({
|
|
153
144
|
[RESOURCE_CLASSES.sqs]:
|
|
@@ -187,8 +187,13 @@ const createGetNodeSnsOut = require('./OutPerActionComplete/OutGetComplete/sns-o
|
|
|
187
187
|
const createWebSocketDynamoDb = require('./flowTag/resources/dynamoDb/data');
|
|
188
188
|
const createWebSocketConnectYaml = require('./flowTag/webSocket/webSocketConnect/functionYaml/data');
|
|
189
189
|
const createWebSocketConnectHandler = require('./flowTag/webSocket/webSocketConnect/handler/data');
|
|
190
|
-
const createWebSocketHandlerYaml = require('./flowTag/webSocket/websocketHandler/functionYaml/data')
|
|
191
|
-
const createWebSocketHandler = require('./flowTag/webSocket/websocketHandler/
|
|
190
|
+
const createWebSocketHandlerYaml = require('./flowTag/webSocket/websocketHandler/functionYaml/data');
|
|
191
|
+
const createWebSocketHandler = require('./flowTag/webSocket/websocketHandler/handler/data');
|
|
192
|
+
const createWebSocketMainFunction = require('./flowTag/webSocket/websocketHandler/mainFunction/data');
|
|
193
|
+
const createWebSocketCompleteFunctionYaml = require('./flowTag/webSocket/webSocketComplete/functionYaml/data');
|
|
194
|
+
const createWebSocketCompleteSqs = require('./flowTag/webSocket/webSocketComplete/sns-sqs/data');
|
|
195
|
+
const createWebSocketCompleteHandler = require('./flowTag/webSocket/webSocketComplete/handler/data');
|
|
196
|
+
const createWebSocketCompleteMainFunction = require('./flowTag/webSocket/webSocketComplete/mainFunction/data')
|
|
192
197
|
|
|
193
198
|
//get functionNameConfig
|
|
194
199
|
const functionNameConfigYamldata = require('./externalService/FunctionNameConfig/data');
|
|
@@ -247,7 +252,7 @@ async function generateCodeWithTemplate(_izContext, objSchemaPath) {
|
|
|
247
252
|
// _izContext.logger.debug("allObjectRelationships::", allObjectRelationships);
|
|
248
253
|
|
|
249
254
|
const allLocalFlowSchemas = await getAllLocalFlowSchemas(_izContext, objSchemaPath);
|
|
250
|
-
_izContext.logger.debug("allLocalFlowSchemas::", allLocalFlowSchemas)
|
|
255
|
+
// _izContext.logger.debug("allLocalFlowSchemas::", allLocalFlowSchemas)
|
|
251
256
|
for (const flowSchema of allLocalFlowSchemas.records) {
|
|
252
257
|
|
|
253
258
|
}
|
|
@@ -256,9 +261,15 @@ async function generateCodeWithTemplate(_izContext, objSchemaPath) {
|
|
|
256
261
|
const webSocketConnectHandler = createWebSocketConnectHandler(_izContext, saveFilePath);
|
|
257
262
|
const webSocketHandlerYaml = createWebSocketHandlerYaml(_izContext, saveFilePath);
|
|
258
263
|
const webSocketHandler = createWebSocketHandler(_izContext, saveFilePath);
|
|
264
|
+
const webSocketMainFunction = createWebSocketMainFunction(_izContext, saveFilePath);
|
|
265
|
+
const webSocketCompleteFunctionYaml = createWebSocketCompleteFunctionYaml(_izContext, saveFilePath);
|
|
266
|
+
const webSocketCompleteQueue = createWebSocketCompleteSqs(_izContext, saveFilePath);
|
|
267
|
+
const webSocketCompleteHandler = createWebSocketCompleteHandler(_izContext, saveFilePath);
|
|
268
|
+
const webSocketCompleteMainFunction = createWebSocketCompleteMainFunction(_izContext, saveFilePath);
|
|
259
269
|
// const webSocketHandler
|
|
260
270
|
|
|
261
|
-
const webSocketResource = [...webSocketTaskTable, ...webSocketConnectYaml, ...webSocketConnectHandler, ...webSocketHandler, ...webSocketHandlerYaml
|
|
271
|
+
const webSocketResource = [...webSocketTaskTable, ...webSocketConnectYaml, ...webSocketConnectHandler, ...webSocketHandler, ...webSocketHandlerYaml,
|
|
272
|
+
...webSocketMainFunction, ...webSocketCompleteQueue, ...webSocketCompleteFunctionYaml, ...webSocketCompleteHandler, ...webSocketCompleteMainFunction]
|
|
262
273
|
if (allLocalFlowSchemas.records.length) {
|
|
263
274
|
createSourceParams.push(
|
|
264
275
|
...webSocketResource
|
|
@@ -287,7 +298,7 @@ async function generateCodeWithTemplate(_izContext, objSchemaPath) {
|
|
|
287
298
|
|
|
288
299
|
// create External service
|
|
289
300
|
const createFunctionIamRole = await createExternalLambdaRole(_izContext, allObjSchemas.records, allObjectRelationships, saveFilePath);
|
|
290
|
-
const createSnsSubscription = await createExternalSnsSubscriptions(_izContext,
|
|
301
|
+
const createSnsSubscription = await createExternalSnsSubscriptions(_izContext, allObjSchemas.records, allObjectRelationships, saveFilePath);
|
|
291
302
|
for (let objectSchema of allObjSchemas.records) {
|
|
292
303
|
|
|
293
304
|
// generate handler perAction
|
package/src/TemplateManager/src/OutPerActionComplete/OutUpdateComplete/mainFunction/template.ejs
CHANGED
|
@@ -86,7 +86,7 @@ module.exports.updateNodeComplete = async (
|
|
|
86
86
|
objectType: returnValue.objType.objectType,
|
|
87
87
|
serviceTag: returnValue.objType.serviceTag
|
|
88
88
|
},
|
|
89
|
-
|
|
89
|
+
objInstanceFull: {
|
|
90
90
|
identifiers: returnValue.objInstanceFull.identifiers,
|
|
91
91
|
fields: returnValue.objInstanceFull.fields
|
|
92
92
|
},
|
|
@@ -70,7 +70,7 @@ module.exports.main = middleware.wrap(async (event,context, callback) => {
|
|
|
70
70
|
|
|
71
71
|
await validateSchemaPerRecord(
|
|
72
72
|
record,
|
|
73
|
-
"<%- functionName %><%- firstLetterUpperCase(handler) %>",
|
|
73
|
+
"<%- firstLetterUpperCase(functionName) %><%- firstLetterUpperCase(handler) %>",
|
|
74
74
|
OBJTYPE,
|
|
75
75
|
"<%- action %>"
|
|
76
76
|
//(<validateSchemaSetting>)
|
|
@@ -81,7 +81,7 @@ module.exports.main = middleware.wrap(async (event,context, callback) => {
|
|
|
81
81
|
/*
|
|
82
82
|
await recordHandlerSharedLib.validateRecord(
|
|
83
83
|
record,
|
|
84
|
-
"<%- functionName %><%- firstLetterUpperCase(handler) %>",
|
|
84
|
+
"<%- firstLetterUpperCase(functionName) %><%- firstLetterUpperCase(handler) %>",
|
|
85
85
|
perRecordsValidatorSchema
|
|
86
86
|
);
|
|
87
87
|
*/
|
|
@@ -68,7 +68,7 @@ module.exports.main = middleware.wrap(async (event,context, callback) => {
|
|
|
68
68
|
|
|
69
69
|
await validateSchemaPerRecord(
|
|
70
70
|
record,
|
|
71
|
-
"<%- functionName %><%- firstLetterUpperCase(handler) %>",
|
|
71
|
+
"<%- firstLetterUpperCase(functionName) %><%- firstLetterUpperCase(handler) %>",
|
|
72
72
|
OBJTYPE,
|
|
73
73
|
"<%- action %>"
|
|
74
74
|
//(<validateSchemaSetting>)
|
|
@@ -79,7 +79,7 @@ module.exports.main = middleware.wrap(async (event,context, callback) => {
|
|
|
79
79
|
/*
|
|
80
80
|
await recordHandlerSharedLib.validateRecord(
|
|
81
81
|
record,
|
|
82
|
-
"<%- functionName %><%- firstLetterUpperCase(handler) %>",
|
|
82
|
+
"<%- firstLetterUpperCase(functionName) %><%- firstLetterUpperCase(handler) %>",
|
|
83
83
|
perRecordsValidatorSchema
|
|
84
84
|
);
|
|
85
85
|
*/
|
|
@@ -28,7 +28,6 @@ const serviceConfigLib = require('@izara_project/izara-core-library-service-sche
|
|
|
28
28
|
|
|
29
29
|
const uploadUseCase = require('@izara_project/izara-core-library-service-schemas/src/libs/UploadUseCase')
|
|
30
30
|
|
|
31
|
-
|
|
32
31
|
const hash = require("object-hash")
|
|
33
32
|
const NoRetryError = require('@izara_project/izara-core-library-core/src/NoRetryError');
|
|
34
33
|
const path = require('path')
|
|
@@ -60,7 +59,6 @@ const { createDataDetailsLib } = require('@izara_project/izara-market-library-se
|
|
|
60
59
|
const { createLinkTypeId } = require('@izara_project/izara-core-library-service-schemas/src/Utils');
|
|
61
60
|
const { findLinksByObjTypes } = require("@izara_project/izara-core-library-service-schemas/src/libs/RelSchemaLib")
|
|
62
61
|
const lodash = require("lodash")
|
|
63
|
-
|
|
64
62
|
/**
|
|
65
63
|
- all storageType( DB and Graph) use objInstance({identifiers,fields})
|
|
66
64
|
- storageType[DB] async
|
|
@@ -285,28 +283,20 @@ module.exports.<%- functionName %>Main = async (
|
|
|
285
283
|
_izContext.logger.debug(":::::case single identifer:::::", identifier);
|
|
286
284
|
|
|
287
285
|
if (objectSchemas.fieldNames[identifier.fieldName].hasOwnProperty("randomOnCreate")) {
|
|
288
|
-
|
|
289
286
|
if ((objectSchemas.fieldNames[identifier.fieldName].randomOnCreate == true)) {
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
uniqueRequestId: _izContext.uniqueRequestId,
|
|
299
|
-
callingFlowConfig: callingFlowConfig
|
|
300
|
-
})
|
|
301
|
-
});
|
|
302
|
-
_izContext.logger.debug("Assign requestParams", requestParams)
|
|
303
|
-
}
|
|
287
|
+
Object.assign(requestParams.fieldNames, {
|
|
288
|
+
[identifier.fieldName]: hash({
|
|
289
|
+
fieldNames: identifier, //
|
|
290
|
+
uniqueRequestId: _izContext.uniqueRequestId,
|
|
291
|
+
callingFlowConfig: callingFlowConfig
|
|
292
|
+
})
|
|
293
|
+
});
|
|
294
|
+
_izContext.logger.debug("Assign requestParams", requestParams)
|
|
304
295
|
|
|
305
296
|
} else if ((objectSchemas.fieldNames[identifier.fieldName].randomOnCreate == false) ||
|
|
306
297
|
(objectSchemas.fieldNames[identifier.fieldName].randomOnCreate == null)) {
|
|
307
298
|
|
|
308
299
|
if ((objectSchemas.fieldNames[identifier.fieldName].requiredOnCreate == true) &&
|
|
309
|
-
((objectSchemas.fieldNames[identifier.fieldName].optionalOnCreate == false) || objectSchemas.fieldNames[identifier.fieldName].optionalOnCreate == true) &&
|
|
310
300
|
(objectSchemas.fieldNames[identifier.fieldName].canUpdate == false)) {
|
|
311
301
|
// check Fns have resive
|
|
312
302
|
|
|
@@ -329,7 +319,6 @@ module.exports.<%- functionName %>Main = async (
|
|
|
329
319
|
};
|
|
330
320
|
}
|
|
331
321
|
|
|
332
|
-
|
|
333
322
|
_izContext.logger.debug("requestParams is:", requestParams);
|
|
334
323
|
|
|
335
324
|
// check settingObjSchemas
|
|
@@ -381,6 +370,10 @@ module.exports.<%- functionName %>Main = async (
|
|
|
381
370
|
}; // end loop
|
|
382
371
|
|
|
383
372
|
let listOfObjectForCreates = [];
|
|
373
|
+
|
|
374
|
+
let objInstanceFullForDynamoDb = lodash.cloneDeep(objInstanceFull)
|
|
375
|
+
let objInstanceFullForGraph = lodash.cloneDeep(objInstanceFull)
|
|
376
|
+
|
|
384
377
|
if (errorsFound.length == 0) {
|
|
385
378
|
|
|
386
379
|
for (let [storageTag, createDataDetail] of Object.entries(createDataDetails)) {
|
|
@@ -388,7 +381,6 @@ module.exports.<%- functionName %>Main = async (
|
|
|
388
381
|
if (createDataDetail.storageType == consts.STORAGE_TYPES.dynamoDB) {
|
|
389
382
|
_izContext.logger.debug("::::::DynamoDB::::::", { storageTag, objInstanceFull });
|
|
390
383
|
|
|
391
|
-
let objInstanceFullForDynamoDb = lodash.cloneDeep(objInstanceFull)
|
|
392
384
|
|
|
393
385
|
Object.assign(objInstanceFullForDynamoDb.fields, createObjInstanceFullFieldsByStorageTag(_izContext, storageTag, createDataDetail))
|
|
394
386
|
_izContext.logger.debug("objInstanceFull before create item in dynamoDB", objInstanceFullForDynamoDb)
|
|
@@ -412,12 +404,9 @@ module.exports.<%- functionName %>Main = async (
|
|
|
412
404
|
...objInstanceFullForDynamoDb.fields
|
|
413
405
|
}
|
|
414
406
|
);
|
|
415
|
-
|
|
416
407
|
} else if (createDataDetail.storageType == consts.STORAGE_TYPES.graph) {
|
|
417
408
|
_izContext.logger.debug("::::::Graph::::::", { storageTag, objInstanceFull });
|
|
418
409
|
|
|
419
|
-
let objInstanceFullForGraph = lodash.cloneDeep(objInstanceFull)
|
|
420
|
-
|
|
421
410
|
Object.assign(objInstanceFullForGraph.fields, createObjInstanceFullFieldsByStorageTag(_izContext, storageTag, createDataDetail))
|
|
422
411
|
_izContext.logger.debug("objInstanceFull before send to Graph", objInstanceFullForGraph)
|
|
423
412
|
|
|
@@ -564,14 +553,37 @@ module.exports.<%- functionName %>Main = async (
|
|
|
564
553
|
errorsFound: errorsFound
|
|
565
554
|
}
|
|
566
555
|
} else {
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
556
|
+
|
|
557
|
+
if (allAwaitingStepsId.length == 0 && listOfObjectForCreates.length == 0) {
|
|
558
|
+
let messageObject = {
|
|
559
|
+
objType: {
|
|
560
|
+
objectType: OBJECT_TYPE,
|
|
561
|
+
serviceTag: SERVICE_TAG
|
|
562
|
+
},
|
|
563
|
+
objInstanceFull: {
|
|
564
|
+
identifiers: objInstanceFullForDynamoDb.identifiers,
|
|
565
|
+
fields: objInstanceFullForDynamoDb.fields
|
|
566
|
+
}
|
|
567
|
+
}
|
|
568
|
+
|
|
569
|
+
if (callingFlowConfig[callingFlowSharedLib.consts.CALLINGFLOW_PROPERTYNAME]) {
|
|
570
|
+
// send message to SNS OutCreateNodeComplete
|
|
571
|
+
_izContext.logger.debug("HAVE CallingFlow");
|
|
572
|
+
messageObject = callingFlowSharedLib.addPassBackPropertiesToSnsResponseMessageObject(callingFlowConfig, messageObject);
|
|
573
|
+
|
|
574
|
+
let messageAttributes = callingFlowSharedLib.addCallingFlowToSnsResponseMessageAttributes(callingFlowConfig, {});
|
|
575
|
+
let outCreateNodeCompleteTopic = await snsSharedLib.snsTopicArn(_izContext, TOPIC_NAME_GENERATE_CODE.outCreateNodeComplete)
|
|
576
|
+
let messageParams = {
|
|
577
|
+
Message: JSON.stringify(messageObject),
|
|
578
|
+
MessageAttributes: sns.createStringMessageAttributes(_izContext, messageAttributes),
|
|
579
|
+
TopicArn: outCreateNodeCompleteTopic,
|
|
580
|
+
};
|
|
581
|
+
|
|
582
|
+
_izContext.logger.debug("messageParams OutCreateNode ::::::: ", messageParams);
|
|
583
|
+
await sns.publishAsync(_izContext, messageParams);
|
|
584
|
+
}
|
|
572
585
|
}
|
|
573
586
|
}
|
|
574
|
-
|
|
575
587
|
} catch (err) {
|
|
576
588
|
throw (err)
|
|
577
589
|
}
|
|
@@ -281,6 +281,34 @@ module.exports.<%- functionName %>Main = async (
|
|
|
281
281
|
identifiersForUpdateData,
|
|
282
282
|
fieldForUpdateTableDynamo
|
|
283
283
|
)
|
|
284
|
+
|
|
285
|
+
if (awaitingStepIds.length == 0) {
|
|
286
|
+
let messageObject = {
|
|
287
|
+
objType: {
|
|
288
|
+
objectType: OBJECT_TYPE,
|
|
289
|
+
serviceTag: SERVICE_TAG
|
|
290
|
+
},
|
|
291
|
+
objInstanceFull: {
|
|
292
|
+
identifiers: identifiersForUpdateData,
|
|
293
|
+
fields: fieldForUpdateTableDynamo
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
if (callingFlowConfig[callingFlowSharedLib.consts.CALLINGFLOWPROPERTIES_PROPERTYNAME]) {
|
|
298
|
+
_izContext.logger.debug("HAVE CALLINGFLOW");
|
|
299
|
+
messageObject = callingFlowSharedLib.addPassBackPropertiesToSnsResponseMessageObject(callingFlowConfig, {});
|
|
300
|
+
let outUpdateNodeCompleteTopic = await snsSharedLib.snsTopicArn(_izContext, TOPIC_NAME_GENERATE_CODE.outUpdateNodeComplete);
|
|
301
|
+
let messageParams = {
|
|
302
|
+
Message: JSON.stringify(messageObject),
|
|
303
|
+
MessageAttributes: sns.createStringMessageAttributes(_izContext, messageAttributes),
|
|
304
|
+
TopicArn: outUpdateNodeCompleteTopic
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
_izContext.logger.debug("message params OutUpdateNodeComplete :::", messageParams);
|
|
308
|
+
await sns.publishAsync(_izContext, messageParams);
|
|
309
|
+
|
|
310
|
+
}
|
|
311
|
+
}
|
|
284
312
|
}
|
|
285
313
|
}
|
|
286
314
|
)
|
|
@@ -59,7 +59,7 @@ module.exports.createRelationshipComplete = async (
|
|
|
59
59
|
returnValue.firstObject.objType,
|
|
60
60
|
returnValue.secondObject.objType,
|
|
61
61
|
returnValue.relType,
|
|
62
|
-
returnValue.
|
|
62
|
+
returnValue.relationshipDirection
|
|
63
63
|
);
|
|
64
64
|
|
|
65
65
|
let awaitingStepId = asyncFlowSharedLib.createAwaitingStepId(
|
|
@@ -59,7 +59,7 @@ module.exports.createRelationshipComplete = async (
|
|
|
59
59
|
returnValue.firstObject.objType,
|
|
60
60
|
returnValue.secondObject.objType,
|
|
61
61
|
returnValue.relType,
|
|
62
|
-
returnValue.
|
|
62
|
+
returnValue.relationshipDirection
|
|
63
63
|
);
|
|
64
64
|
|
|
65
65
|
let awaitingStepId = asyncFlowSharedLib.createAwaitingStepId(
|
|
@@ -60,7 +60,7 @@ module.exports.updateRelationshipComplete = async (
|
|
|
60
60
|
returnValue.firstObject.objType,
|
|
61
61
|
returnValue.secondObject.objType,
|
|
62
62
|
returnValue.relType,
|
|
63
|
-
returnValue.
|
|
63
|
+
returnValue.relationshipDirection
|
|
64
64
|
);
|
|
65
65
|
|
|
66
66
|
let awaitingStepId = asyncFlowSharedLib.createAwaitingStepId(
|
|
@@ -109,6 +109,21 @@ const createAwaitingMultipleStepDynamoDbData = (_izContext, srcPath) => {
|
|
|
109
109
|
"AttributeType": "S"
|
|
110
110
|
}
|
|
111
111
|
]
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
"tableName": "AwaitingStep",
|
|
115
|
+
"attributes": [
|
|
116
|
+
{
|
|
117
|
+
"keyType": "partitionKey",
|
|
118
|
+
"AttributeName": "awaitingStepId",
|
|
119
|
+
"AttributeType": "S"
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
"keyType": "sortKey",
|
|
123
|
+
"AttributeName": "pendingStepId",
|
|
124
|
+
"AttributeType": "S"
|
|
125
|
+
}
|
|
126
|
+
]
|
|
112
127
|
}
|
|
113
128
|
)
|
|
114
129
|
|
|
@@ -25,7 +25,7 @@ const { getGraphServiceNameFromGraphServerTagWithCache,
|
|
|
25
25
|
} = require('@izara_project/izara-core-library-service-schemas/src/ServiceConfig')
|
|
26
26
|
|
|
27
27
|
const { firstLetterLowerCase: lowerCase, firstLetterUpperCase: upperCase } = require("../../../../MainLibs/src/Utils")
|
|
28
|
-
const { DEFAULT_HANDLER_PER_ACTION, createIamRole, RESOURCE_CLASSES, SOURCE_PATH, externalResourceName, externalResourceSns, getGraphServiceNameFromAllRelSchema, SAVE_FILE_NAME, LAMBDA_RESOURCE, SNS_RESOURCE, getGraphServiceNameFromObjectSchema, shortNameHandler, SHORT_FUNCTION_NAME } = require("../../libs/Consts");
|
|
28
|
+
const { DEFAULT_HANDLER_PER_ACTION, createIamRole, RESOURCE_CLASSES, SOURCE_PATH, externalResourceName, externalResourceSns, getGraphServiceNameFromAllRelSchema, SAVE_FILE_NAME, LAMBDA_RESOURCE, SNS_RESOURCE, getGraphServiceNameFromObjectSchema, shortNameHandler, SHORT_FUNCTION_NAME, defaultIamRolePerAction } = require("../../libs/Consts");
|
|
29
29
|
// const templatePath = path.join(__dirname, "./template.ejs");
|
|
30
30
|
const templatePath = path.join(__dirname, "./template.ejs");
|
|
31
31
|
const { getAllLocalRelationshipSchemas } = require('@izara_project/izara-core-library-service-schemas/src/GetObjectSchema')
|
|
@@ -75,9 +75,8 @@ const createExternalLambdaRole = async (_izContext, allObjSchemas, allRelSchemas
|
|
|
75
75
|
}
|
|
76
76
|
|
|
77
77
|
// findData external lambda role
|
|
78
|
-
const externalLambdaIamRoleFindData =
|
|
78
|
+
const externalLambdaIamRoleFindData = externalLambdaIamRoleDataFindData(_izContext);
|
|
79
79
|
externalLambdaIamRoleFindData && externalLambdaIamRoleArray.push(externalLambdaIamRoleFindData)
|
|
80
|
-
// processLogical
|
|
81
80
|
|
|
82
81
|
|
|
83
82
|
// updateRelationshipComplete external lambda role
|
|
@@ -255,33 +254,21 @@ async function externalLambdaIamRoleDataDeleteRelationshipSchema(_izContext, all
|
|
|
255
254
|
}
|
|
256
255
|
}
|
|
257
256
|
|
|
258
|
-
|
|
257
|
+
function externalLambdaIamRoleDataFindData(_izContext) {
|
|
259
258
|
let functionName = upperCase(SHORT_FUNCTION_NAME.findData) + upperCase(shortNameHandler(HANDLER.hdrSqs));
|
|
260
259
|
let additionalResourcePermission = [];
|
|
261
|
-
let graphServiceNames = []
|
|
262
|
-
for (const objectSchema of allObjSchemas) {
|
|
263
|
-
for (const storgaeResource of Object.values(objectSchema.storageResources)) {
|
|
264
|
-
if (storgaeResource.storageType === STORAGE_TYPES.graph) {
|
|
265
|
-
let getGraphServiceName = await getGraphServiceNameFromGraphServerTagWithCache(_izContext, storgaeResource.graphServerTag)
|
|
266
|
-
if (!graphServiceNames.includes(getGraphServiceName)) {
|
|
267
|
-
graphServiceNames.push(getGraphServiceName)
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
|
-
}
|
|
271
|
-
}
|
|
272
|
-
|
|
273
260
|
|
|
274
261
|
additionalResourcePermission.push(
|
|
275
262
|
createIamRole(
|
|
276
263
|
{
|
|
277
264
|
[RESOURCE_CLASSES.lambda]: [LAMBDA_RESOURCE.invokeFunction]
|
|
278
265
|
},
|
|
279
|
-
|
|
280
|
-
externalResourceName(RESOURCE_CLASSES.lambda, "GetNodeV2HdrInv",
|
|
281
|
-
|
|
282
|
-
)
|
|
266
|
+
[
|
|
267
|
+
externalResourceName(RESOURCE_CLASSES.lambda, "GetNodeV2HdrInv", "GraphHandler")
|
|
268
|
+
]
|
|
283
269
|
)
|
|
284
270
|
)
|
|
271
|
+
console.log("findData template data:", { functionName, additionalResourcePermission })
|
|
285
272
|
return {
|
|
286
273
|
functionName,
|
|
287
274
|
additionalResourcePermission
|
|
@@ -30,7 +30,7 @@ const {
|
|
|
30
30
|
const templatePath = path.join(__dirname, "./template.ejs");
|
|
31
31
|
|
|
32
32
|
|
|
33
|
-
const createExternalSnsSubscriptions = async (_izContext,
|
|
33
|
+
const createExternalSnsSubscriptions = async (_izContext, allObjSchemas, allRelSchemas, srcPath) => {
|
|
34
34
|
const snsServiceConfigArray = [];
|
|
35
35
|
|
|
36
36
|
const snsServiceConfigUpdateRelationshipComplete = await snsSubScriptionUpdateRelationshipComplete(_izContext, allRelSchemas)
|
|
@@ -0,0 +1,100 @@
|
|
|
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
|
+
'use strict';
|
|
19
|
+
|
|
20
|
+
const path = require('path');
|
|
21
|
+
|
|
22
|
+
const templatePath = path.join(__dirname, "./template.ejs")
|
|
23
|
+
|
|
24
|
+
const { HANDLER, STORAGE_TYPES, ACTIONS } = require('@izara_project/izara-core-library-service-schemas/src/Consts')
|
|
25
|
+
const { firstLetterLowerCase: lowerCase, firstLetterUpperCase: upperCase } = require("../../../../../../MainLibs/src/Utils")
|
|
26
|
+
const { createIamRole, resourceNames, RESOURCE_CLASSES, DEFAULT_LAMBDA_ROLE_PER_ACTION, SQS_RESOURCE, SOURCE_PATH, SAVE_FILE_NAME, FUNCTION_NAME, shortNameHandler, defaultIamRolePerAction, DYNAMO_RESOURCE } = require("../../../../libs/Consts");
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* receive objectSchema
|
|
31
|
+
* create data for FindData Yaml template
|
|
32
|
+
*
|
|
33
|
+
* @param {Object} objectSchemas
|
|
34
|
+
* @return {{ templatePath, templateData, setting } }
|
|
35
|
+
*/
|
|
36
|
+
function data(_izContext, srcPath) {
|
|
37
|
+
return [createSourceParams(_izContext, srcPath)]
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function createSourceParams(_izContext, srcPath) {
|
|
41
|
+
let functionName = "WebSocketTaskComplete";
|
|
42
|
+
let handlerType = upperCase(HANDLER.hdrSqs);
|
|
43
|
+
let additionalResourcePermission = defaultIamRolePerAction();
|
|
44
|
+
|
|
45
|
+
additionalResourcePermission.push(
|
|
46
|
+
createIamRole(
|
|
47
|
+
{
|
|
48
|
+
[RESOURCE_CLASSES.sqs]: [
|
|
49
|
+
SQS_RESOURCE.sendMessage,
|
|
50
|
+
SQS_RESOURCE.deleteMessage,
|
|
51
|
+
SQS_RESOURCE.getQueueAttributes,
|
|
52
|
+
SQS_RESOURCE.receiveMessage
|
|
53
|
+
]
|
|
54
|
+
},
|
|
55
|
+
[
|
|
56
|
+
resourceNames(RESOURCE_CLASSES.sns, functionName + handlerType),
|
|
57
|
+
resourceNames(RESOURCE_CLASSES.sns, functionName + "DLQ")
|
|
58
|
+
]
|
|
59
|
+
),
|
|
60
|
+
createIamRole(
|
|
61
|
+
{
|
|
62
|
+
[RESOURCE_CLASSES.dynamoDbTable]: [
|
|
63
|
+
DYNAMO_RESOURCE.query,
|
|
64
|
+
DYNAMO_RESOURCE.deleteItem,
|
|
65
|
+
]
|
|
66
|
+
},
|
|
67
|
+
[
|
|
68
|
+
resourceNames(RESOURCE_CLASSES.dynamoDbTable, "WebSocketTask")
|
|
69
|
+
]
|
|
70
|
+
),
|
|
71
|
+
createIamRole(
|
|
72
|
+
{
|
|
73
|
+
"execute-api": [
|
|
74
|
+
"ManageConnections"
|
|
75
|
+
]
|
|
76
|
+
},
|
|
77
|
+
[
|
|
78
|
+
resourceNames(RESOURCE_CLASSES.webSocket)
|
|
79
|
+
]
|
|
80
|
+
)
|
|
81
|
+
)
|
|
82
|
+
|
|
83
|
+
return {
|
|
84
|
+
templatePath: templatePath,
|
|
85
|
+
templateData: {
|
|
86
|
+
resourceLocation: SOURCE_PATH.resourceLocationWebSocket,
|
|
87
|
+
functionName: functionName,
|
|
88
|
+
handlerType: handlerType,
|
|
89
|
+
additionalResourcePermission: additionalResourcePermission
|
|
90
|
+
},
|
|
91
|
+
setting: {
|
|
92
|
+
savePath: path.join(srcPath, SOURCE_PATH.appYaml),
|
|
93
|
+
saveFileName: SAVE_FILE_NAME.flowSchema,
|
|
94
|
+
fileExtension: ".yml",
|
|
95
|
+
isAppend: true
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
module.exports = data;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
<%_ const join = require('path').join; _%>
|
|
2
|
+
<%- firstLetterUpperCase(functionName) %><%- handlerType -%>:
|
|
3
|
+
handler: <%- join(resourceLocation, `${functionName}_${firstLetterUpperCase(handlerType)}.main`)%>
|
|
4
|
+
name: ${self:custom.iz_resourcePrefix}<%- functionName %><%- firstLetterUpperCase(handlerType) %>
|
|
5
|
+
events:
|
|
6
|
+
- sqs:
|
|
7
|
+
arn: arn:aws:sqs:${self:custom.iz_region}:${self:custom.iz_accountId}:${self:custom.iz_resourcePrefix}<%- functionName %><%- firstLetterUpperCase(handlerType) %>
|
|
8
|
+
batchSize: 10
|
|
9
|
+
iamRoleStatements:
|
|
10
|
+
<%_ additionalResourcePermission.forEach(resourcePermission => { _%>
|
|
11
|
+
- Effect: <%- resourcePermission.effect %>
|
|
12
|
+
Action:
|
|
13
|
+
<%_ Object.keys(resourcePermission.action).forEach(resourcePerAction => { _%>
|
|
14
|
+
<%_ resourcePermission.action[resourcePerAction].forEach(permission => { _%>
|
|
15
|
+
- <%- resourcePerAction %>:<%- permission %>
|
|
16
|
+
<%_ }) _%>
|
|
17
|
+
<%_ }) _%>
|
|
18
|
+
Resource:
|
|
19
|
+
<%_ resourcePermission.resource.forEach(resource => { _%>
|
|
20
|
+
- "<%- resource %>"
|
|
21
|
+
<%_ }) _%>
|
|
22
|
+
<%_}) _%>
|
|
23
|
+
#<#<%- functionName %><%- handlerType %>IamRole#>
|
|
24
|
+
#<#/<%- functionName %><%- handlerType %>IamRole#>
|
|
25
|
+
<%_ function firstLetterUpperCase(text){
|
|
26
|
+
return text.charAt(0).toUpperCase() + text.slice(1)
|
|
27
|
+
} _%>
|
|
@@ -0,0 +1,58 @@
|
|
|
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
|
+
'use strict';
|
|
19
|
+
|
|
20
|
+
const path = require('path');
|
|
21
|
+
|
|
22
|
+
const templatePath = path.join(__dirname, "./template.ejs")
|
|
23
|
+
|
|
24
|
+
const { HANDLER, STORAGE_TYPES, ACTIONS } = require('@izara_project/izara-core-library-service-schemas/src/Consts')
|
|
25
|
+
const { firstLetterLowerCase: lowerCase, firstLetterUpperCase: upperCase } = require("../../../../../../MainLibs/src/Utils")
|
|
26
|
+
const { createIamRole, resourceNames, RESOURCE_CLASSES, DEFAULT_LAMBDA_ROLE_PER_ACTION, SQS_RESOURCE, SOURCE_PATH, SAVE_FILE_NAME, FUNCTION_NAME, shortNameHandler, defaultIamRolePerAction, DYNAMO_RESOURCE } = require("../../../../libs/Consts");
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* receive objectSchema
|
|
31
|
+
* create data for FindData Yaml template
|
|
32
|
+
*
|
|
33
|
+
* @param {Object} objectSchemas
|
|
34
|
+
* @return {{ templatePath, templateData, setting } }
|
|
35
|
+
*/
|
|
36
|
+
function data(_izContext, srcPath) {
|
|
37
|
+
return [createSourceParams(_izContext, srcPath)]
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function createSourceParams(_izContext, srcPath) {
|
|
41
|
+
let functionName = "WebSocketTaskComplete"
|
|
42
|
+
let handlerType = upperCase(HANDLER.hdrSqs)
|
|
43
|
+
return {
|
|
44
|
+
templatePath: templatePath,
|
|
45
|
+
templateData: {
|
|
46
|
+
functionName,
|
|
47
|
+
handlerType,
|
|
48
|
+
},
|
|
49
|
+
setting: {
|
|
50
|
+
savePath: path.join(srcPath, SOURCE_PATH.webSocket),
|
|
51
|
+
saveFileName: `${functionName}_${handlerType}`,
|
|
52
|
+
fileExtension: ".js",
|
|
53
|
+
isAppend: false
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
module.exports = data;
|