@izara_project/izara-market-library-service-schemas 1.0.62 → 1.0.64
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/GenerateCodeLibs/src/Consts.js +7 -3
- package/src/MainLibs/src/Consts.js +6 -2
- package/src/reStructure/GenerateCode.js +1 -1
- package/src/reStructure/TemplateData/EndpointPerService/mainFunction/create/template.ejs +20 -8
- package/src/reStructure/TemplateData/EndpointPerService/mainFunction/update/template.ejs +114 -83
- package/src/reStructure/TemplateData/externalService/lambdaRole/data.js +8 -0
- package/src/reStructure/TemplateData/externalService/snsTopicSubscriptions/data.js +11 -1
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaComponent/handler/template.ejs +13 -7
- package/src/reStructure/TemplateData/flowSchema/generateTemplateData.js +3 -2
- package/src/reStructure/TemplateData/flowSchema/register/complete/handler/template.ejs +1 -0
- package/src/reStructure/TemplateData/flowSchema/register/complete/mainFunction/template.ejs +3 -1
- package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/functionYaml/api/data.js +123 -0
- package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/functionYaml/api/template.ejs +20 -0
- package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/functionYaml/dsq/data.js +122 -0
- package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/functionYaml/dsq/template.ejs +17 -0
- package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/functionYaml/inv/data.js +123 -0
- package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/functionYaml/inv/template.ejs +13 -0
- package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/functionYaml/sqs/data.js +123 -0
- package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/functionYaml/sqs/template.ejs +17 -0
- package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/handler/api/data.js +57 -0
- package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/handler/api/request.json +0 -0
- package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/handler/api/template.ejs +155 -0
- package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/handler/dsq/data.js +58 -0
- package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/handler/dsq/request.json +0 -0
- package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/handler/dsq/template.ejs +202 -0
- package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/handler/inv/data.js +59 -0
- package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/handler/inv/request.json +0 -0
- package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/handler/inv/template.ejs +144 -0
- package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/handler/sqs/data.js +59 -0
- package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/handler/sqs/request.json +0 -0
- package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/handler/sqs/template.ejs +181 -0
- package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/mainFunction/data.js +59 -0
- package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/mainFunction/template.ejs +382 -0
- package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/sns-in-sqs/data.js +77 -0
- package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/sns-in-sqs/snsTemplate.ejs +59 -0
- package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/sns-in-sqs/sqsTemplate.ejs +43 -0
- package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/complete/functionYaml/data.js +121 -0
- package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/complete/functionYaml/template.ejs +20 -0
- package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/complete/handler/sqs/data.js +60 -0
- package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/complete/handler/sqs/template.ejs +129 -0
- package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/complete/mainFunction/data.js +55 -0
- package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/complete/mainFunction/template.ejs +154 -0
- package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/complete/sns-in-sqs/data.js +71 -0
- package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/complete/sns-in-sqs/template.ejs +46 -0
- package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/complete/sns-out/data.js +71 -0
- package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/complete/sns-out/template.ejs +10 -0
- package/src/reStructure/TemplateData/relationshipPerAction/create/complete/handler/sqs/template.ejs +2 -2
- package/src/reStructure/TemplateData/relationshipPerAction/generateTemplateData.js +55 -2
package/package.json
CHANGED
|
@@ -25,7 +25,8 @@ const PREFIX = {
|
|
|
25
25
|
deleteRel: "deleteRelationshipEndpoint",
|
|
26
26
|
updateNode: "updateNodeEndpoint",
|
|
27
27
|
createNode: "createNodeEndpoint",
|
|
28
|
-
getRel: "getRelationshipEndpoint"
|
|
28
|
+
getRel: "getRelationshipEndpoint",
|
|
29
|
+
changeRel: "changeRelationshipEndpoint"
|
|
29
30
|
}
|
|
30
31
|
|
|
31
32
|
// const TOPIC_NAME_GRAPH_HANDLER = {
|
|
@@ -55,7 +56,9 @@ const TOPIC_NAME_GRAPH_HANDLER = {
|
|
|
55
56
|
inCreateNode: "CreateNode_In",
|
|
56
57
|
outCreateNode: "CreateNode_Out",
|
|
57
58
|
inDeleteNode: "DeleteNode_In",
|
|
58
|
-
outDeleteNode: "DeleteNode_Out"
|
|
59
|
+
outDeleteNode: "DeleteNode_Out",
|
|
60
|
+
inChangeRelationship: "ChangeRelationshipType_In",
|
|
61
|
+
outChangeRelationship: "ChangeRelationshipType_Out"
|
|
59
62
|
}
|
|
60
63
|
|
|
61
64
|
const TOPIC_NAME_GENERATE_CODE = {
|
|
@@ -79,7 +82,8 @@ const TOPIC_NAME_GENERATE_CODE = {
|
|
|
79
82
|
createPresignUrl: "CreatePresignUrl",
|
|
80
83
|
flowSchemaOwnTopicComplete: "FlowSchemaOwnTopicComplete",
|
|
81
84
|
flowSchemaOwnTopicEndpointComplete: "FlowSchemaOwnTopicEndpointComplete",
|
|
82
|
-
createRecordComplete: "CreateRecordComplete"
|
|
85
|
+
createRecordComplete: "CreateRecordComplete",
|
|
86
|
+
changeRelationshipComplete: "ChangeRelationshipComplete"
|
|
83
87
|
}
|
|
84
88
|
|
|
85
89
|
const GRAPH_HANDLER_SERVICE_NAME = {
|
|
@@ -58,7 +58,7 @@ function resourceNames(resourceClass, resourceName) {
|
|
|
58
58
|
[RESOURCE_CLASSES.dynamoDbTable]: "arn:aws:dynamodb:${self:custom.iz_region}:${self:custom.iz_accountId}:table/${self:custom.iz_resourcePrefix}" + resourceName,
|
|
59
59
|
[RESOURCE_CLASSES.sns]: "arn:aws:sns:${self:custom.iz_region}:${self:custom.iz_accountId}:${self:custom.iz_serviceTag}_${self:custom.iz_stage}_" + resourceName,
|
|
60
60
|
[RESOURCE_CLASSES.lambda]: "arn:aws:lambda:${self:custom.iz_region}:${self:custom.iz_accountId}:function:${self:custom.iz_resourcePrefix}" + resourceName,
|
|
61
|
-
[RESOURCE_CLASSES.webSocket]: "arn:aws:execute-api:${self:custom.iz_region}:${self:custom.iz_accountId}:${self:custom.iz_webSocketHostId}/
|
|
61
|
+
[RESOURCE_CLASSES.webSocket]: "arn:aws:execute-api:${self:custom.iz_region}:${self:custom.iz_accountId}:${self:custom.iz_webSocketHostId}/${self:custom.iz_stage}/POST/@connections/{connectionId}"
|
|
62
62
|
}[resourceClass];
|
|
63
63
|
}
|
|
64
64
|
|
|
@@ -285,6 +285,8 @@ const FUNCTION_NAME = {
|
|
|
285
285
|
flowSchemaEventBridge: "EventBridge",
|
|
286
286
|
createRecordComplete: "createRecordComplete",
|
|
287
287
|
flowSchemaRegister: "register",
|
|
288
|
+
changeRel: "changeRelationship",
|
|
289
|
+
changeRelComplete: "changeRelationshipComplete"
|
|
288
290
|
};
|
|
289
291
|
|
|
290
292
|
const SHORT_FUNCTION_NAME = {
|
|
@@ -307,7 +309,9 @@ const SHORT_FUNCTION_NAME = {
|
|
|
307
309
|
deleteNodeComplete: "deleteNodeComp",
|
|
308
310
|
createObjectS3Complete: "webSocketTaskComp",
|
|
309
311
|
getRel: "getRel",
|
|
310
|
-
getRelComplete: "getRelComp"
|
|
312
|
+
getRelComplete: "getRelComp",
|
|
313
|
+
changeRel: "changeRel",
|
|
314
|
+
changeRelComplete: "changeRelComp"
|
|
311
315
|
}
|
|
312
316
|
|
|
313
317
|
const getGraphServiceNameFromAllRelSchema = async (_izContext, allRelSchemas, settings = { bucketName: OBJECT_SCHEMA_BUCKET_NAME }) => {
|
|
@@ -67,7 +67,7 @@ async function generateCodeWithTemplate(_izContext, objSchemaPath, settings = {}
|
|
|
67
67
|
for (const templateName in templateConfig.TemplateAndData) {
|
|
68
68
|
// Display log indicating which template is being loaded
|
|
69
69
|
// console.log('Loading template:', templateName);
|
|
70
|
-
|
|
70
|
+
console.log("templateName", templateName)
|
|
71
71
|
let generateTemplateData = require(join(__dirname, templateConfig.TemplateAndData[templateName]));
|
|
72
72
|
let createSourceResult = await generateTemplateData(_izContext, objSchemaPath, settings);
|
|
73
73
|
|
|
@@ -31,7 +31,7 @@ const callingFlowSharedLib = require('@izara_project/izara-core-library-calling-
|
|
|
31
31
|
const lambdaSharedLib = require('@izara_project/izara-core-library-lambda');
|
|
32
32
|
const NoRetryError = require('@izara_project/izara-core-library-core/src/NoRetryError');
|
|
33
33
|
const coreConsts = require('@izara_project/izara-core-library-core/src/Consts');
|
|
34
|
-
|
|
34
|
+
const { createRandomIdentifier } = require('@izara_project/izara-core-library-core').IdentifierLib
|
|
35
35
|
// ──────────────────────── Middleware / External ────────────────────────
|
|
36
36
|
const middlewareConsts = require('@izara_project/izara-middleware').consts;
|
|
37
37
|
const externalRequest = require('@izara_project/izara-core-library-external-request');
|
|
@@ -126,6 +126,11 @@ module.exports.createMain = async (
|
|
|
126
126
|
);
|
|
127
127
|
_izContext.logger.debug("objectSchemas", objectSchemas);
|
|
128
128
|
|
|
129
|
+
let parentObject
|
|
130
|
+
if (objectSchemas.hasOwnProperty("extendObjType")) {
|
|
131
|
+
parentObject = await getObjectSchema.getObjSchemaS3WithHierarchy(_izContext, objectSchema.extendObjType)
|
|
132
|
+
}
|
|
133
|
+
|
|
129
134
|
let userAgent = _izContext.correlationIds.get(middlewareConsts.USER_AGENT)
|
|
130
135
|
_izContext.logger.debug("userAgent::", userAgent);
|
|
131
136
|
|
|
@@ -170,12 +175,12 @@ module.exports.createMain = async (
|
|
|
170
175
|
_izContext.logger.debug(":::::case single identifier:::::", identifier);
|
|
171
176
|
|
|
172
177
|
if (objectSchemas.fieldNames[identifier.fieldName].hasOwnProperty("randomOnCreate") && (objectSchemas.fieldNames[identifier.fieldName].randomOnCreate == true)) {
|
|
173
|
-
Object.assign(
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
178
|
+
Object.assign(
|
|
179
|
+
requestParams.fieldNames, {
|
|
180
|
+
[identifier.fieldName]: await createRandomIdentifier(
|
|
181
|
+
_izContext,
|
|
182
|
+
objType
|
|
183
|
+
)
|
|
179
184
|
});
|
|
180
185
|
_izContext.logger.debug("Assign requestParams", requestParams)
|
|
181
186
|
} else if (objectSchemas.fieldNames[identifier.fieldName].hasOwnProperty("hashOnCreate")) {
|
|
@@ -304,6 +309,13 @@ module.exports.createMain = async (
|
|
|
304
309
|
//(</beforeCreateRecordDynamo>)
|
|
305
310
|
_izContext.logger.debug("::::::DynamoDB::::::", { storageTag, objInstanceFull });
|
|
306
311
|
|
|
312
|
+
if (parentObject) {
|
|
313
|
+
if (createDataDetail.tableName.includes(firstLetterUpperCase(`${parentObject.objectType}Records`))) {
|
|
314
|
+
Object.assign(
|
|
315
|
+
objInstanceFullForDynamoDb.fields,
|
|
316
|
+
{ [`${parentObject.objectType}HandlerServiceTag`]: process.env.iz_serviceTag })
|
|
317
|
+
}
|
|
318
|
+
}
|
|
307
319
|
|
|
308
320
|
Object.assign(objInstanceFullForDynamoDb.fields, createObjInstanceFullFieldsByStorageTag(_izContext, storageTag, createDataDetail))
|
|
309
321
|
_izContext.logger.debug("objInstanceFull before create item in dynamoDB", objInstanceFullForDynamoDb)
|
|
@@ -432,7 +444,7 @@ module.exports.createMain = async (
|
|
|
432
444
|
objInstanceFullForGraph,
|
|
433
445
|
requestParams.relationships || [],
|
|
434
446
|
Date.now(),
|
|
435
|
-
{ updatePropertiesOnMatch: false }
|
|
447
|
+
{ updatePropertiesOnMatch: false }
|
|
436
448
|
)
|
|
437
449
|
return createNodeResult
|
|
438
450
|
|
|
@@ -88,8 +88,8 @@ module.exports.updateMain = async (
|
|
|
88
88
|
callingFlowConfig
|
|
89
89
|
});
|
|
90
90
|
|
|
91
|
-
const returnSystemFieldsName = requestParams
|
|
92
|
-
const returnOldData = requestParams
|
|
91
|
+
const returnSystemFieldsName = requestParams?.additionalParams?.settings?.returnSystemFieldsName ?? false;
|
|
92
|
+
const returnOldData = requestParams?.additionalParams?.settings?.returnOldData ?? false;
|
|
93
93
|
|
|
94
94
|
let errorsFound = [];
|
|
95
95
|
|
|
@@ -218,7 +218,7 @@ module.exports.updateMain = async (
|
|
|
218
218
|
}
|
|
219
219
|
|
|
220
220
|
let awaitingStepIds = [];
|
|
221
|
-
|
|
221
|
+
let updateItem;
|
|
222
222
|
function createObjInstanceFullFieldsByStorageTag(_izContext, storageTag, updateDataDetail) {
|
|
223
223
|
let fields = {};
|
|
224
224
|
for (let fieldName of Object.keys(requestParams.objInstanceFull.fields)) {
|
|
@@ -247,35 +247,6 @@ module.exports.updateMain = async (
|
|
|
247
247
|
//(<beforeUpdateGraph>)
|
|
248
248
|
//(</beforeUpdateGraph>)
|
|
249
249
|
|
|
250
|
-
awaitingStepIds.push( // createAwaitingStepId if updateGraph
|
|
251
|
-
asyncFlowSharedLib.createAwaitingStepId(
|
|
252
|
-
hash({
|
|
253
|
-
objectType: objType.objectType,
|
|
254
|
-
serviceTag: objType.serviceTag,
|
|
255
|
-
identifiers: identifiers,
|
|
256
|
-
fields: fields,
|
|
257
|
-
// correlationIds: _izContext.correlationIds.get("id")
|
|
258
|
-
}),
|
|
259
|
-
PREFIX.updateNode
|
|
260
|
-
)
|
|
261
|
-
)
|
|
262
|
-
_izContext.logger.debug("awaitingStepIds", awaitingStepIds)
|
|
263
|
-
|
|
264
|
-
if (awaitingStepIds.length) {
|
|
265
|
-
let awaitingMultipleStep = await asyncFlowSharedLib.createAwaitingMultipleSteps(
|
|
266
|
-
_izContext,
|
|
267
|
-
awaitingStepIds,
|
|
268
|
-
asyncFlowSharedLib.createPendingStepId(
|
|
269
|
-
hash(
|
|
270
|
-
{
|
|
271
|
-
identifiers,
|
|
272
|
-
fields,
|
|
273
|
-
})
|
|
274
|
-
)
|
|
275
|
-
)
|
|
276
|
-
_izContext.logger.debug("awaitingMultipleStep", awaitingMultipleStep)
|
|
277
|
-
}
|
|
278
|
-
|
|
279
250
|
let updateNodeParams = {
|
|
280
251
|
objType: objType,
|
|
281
252
|
objInstanceFull: {
|
|
@@ -290,32 +261,65 @@ module.exports.updateMain = async (
|
|
|
290
261
|
}
|
|
291
262
|
}
|
|
292
263
|
|
|
293
|
-
updateNodeParams
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
264
|
+
if (Object.keys(updateNodeParams.objInstanceFull.fields).length === 0) {
|
|
265
|
+
return
|
|
266
|
+
} else {
|
|
267
|
+
|
|
268
|
+
awaitingStepIds.push( // createAwaitingStepId if updateGraph
|
|
269
|
+
asyncFlowSharedLib.createAwaitingStepId(
|
|
270
|
+
hash({
|
|
271
|
+
objectType: objType.objectType,
|
|
272
|
+
serviceTag: objType.serviceTag,
|
|
273
|
+
identifiers: identifiers,
|
|
274
|
+
fields: fields,
|
|
275
|
+
// correlationIds: _izContext.correlationIds.get("id")
|
|
276
|
+
}),
|
|
277
|
+
PREFIX.updateNode
|
|
301
278
|
)
|
|
302
279
|
)
|
|
303
|
-
|
|
280
|
+
_izContext.logger.debug("awaitingStepIds", awaitingStepIds)
|
|
281
|
+
|
|
282
|
+
if (awaitingStepIds.length) {
|
|
283
|
+
let awaitingMultipleStep = await asyncFlowSharedLib.createAwaitingMultipleSteps(
|
|
284
|
+
_izContext,
|
|
285
|
+
awaitingStepIds,
|
|
286
|
+
asyncFlowSharedLib.createPendingStepId(
|
|
287
|
+
hash(
|
|
288
|
+
{
|
|
289
|
+
identifiers,
|
|
290
|
+
fields,
|
|
291
|
+
})
|
|
292
|
+
)
|
|
293
|
+
)
|
|
294
|
+
_izContext.logger.debug("awaitingMultipleStep", awaitingMultipleStep)
|
|
295
|
+
}
|
|
304
296
|
|
|
305
|
-
|
|
297
|
+
updateNodeParams = callingFlowSharedLib.addCallingFlowToSnsRequestMessageObject(
|
|
298
|
+
updateNodeParams,
|
|
299
|
+
callingFlowSharedLib.addParentCallingFlowConfig(
|
|
300
|
+
callingFlowConfig,
|
|
301
|
+
callingFlowSharedLib.createCallingFlowConfig(
|
|
302
|
+
//(<callingFlowProperties>)
|
|
303
|
+
await lambdaSharedLib.lambdaFunctionName(_izContext, TOPIC_NAME_GENERATE_CODE.updateNodeComplete), {}
|
|
304
|
+
//(</callingFlowProperties>)
|
|
305
|
+
)
|
|
306
|
+
)
|
|
307
|
+
)
|
|
306
308
|
|
|
309
|
+
_izContext.logger.debug("messageObject before send message:", updateNodeParams);
|
|
307
310
|
|
|
308
|
-
let updateNodeMessageBody = {
|
|
309
|
-
Message: JSON.stringify(updateNodeParams),
|
|
310
|
-
MessageAttributes: sns.createStringMessageAttributes(_izContext, messageAttributes),
|
|
311
|
-
TopicArn: await snsSharedLib.snsTopicArnByFlowSchema(_izContext, TOPIC_NAME_GRAPH_HANDLER.inUpdateNode, storageTag)
|
|
312
|
-
}
|
|
313
311
|
|
|
314
|
-
|
|
312
|
+
let updateNodeMessageBody = {
|
|
313
|
+
Message: JSON.stringify(updateNodeParams),
|
|
314
|
+
MessageAttributes: sns.createStringMessageAttributes(_izContext, messageAttributes),
|
|
315
|
+
TopicArn: await snsSharedLib.snsTopicArnByFlowSchema(_izContext, TOPIC_NAME_GRAPH_HANDLER.inUpdateNode, storageTag)
|
|
316
|
+
}
|
|
315
317
|
|
|
316
|
-
|
|
317
|
-
_izContext.logger.debug('resSNS send to topic InUpdateNode finish!', resSNS);
|
|
318
|
+
_izContext.logger.debug('request param before send to topic InUpdateNode:::', updateNodeMessageBody);
|
|
318
319
|
|
|
320
|
+
let resSNS = await sns.publishAsync(_izContext, updateNodeMessageBody)
|
|
321
|
+
_izContext.logger.debug('resSNS send to topic InUpdateNode finish!', resSNS);
|
|
322
|
+
}
|
|
319
323
|
} else if (updateDataDetail.storageType === consts.STORAGE_TYPES.dynamoDB) {
|
|
320
324
|
|
|
321
325
|
let identifiersForUpdateData = await dynamoDbIdentifiersByStorageResource(
|
|
@@ -332,47 +336,74 @@ module.exports.updateMain = async (
|
|
|
332
336
|
|
|
333
337
|
//(<beforeUpdateDynamoDb>)
|
|
334
338
|
//(</beforeUpdateDynamoDb>)
|
|
339
|
+
let fields = createObjInstanceFullFieldsByStorageTag(_izContext, storageTag, updateDataDetail)
|
|
340
|
+
if (Object.keys(fields).length === 0) {
|
|
341
|
+
return
|
|
342
|
+
} else {
|
|
343
|
+
updateItem = await dynamodbSharedLib.updateItem(
|
|
344
|
+
_izContext,
|
|
345
|
+
await dynamodbSharedLib.tableName(_izContext, updateDataDetail.tableName, updateDataDetail.serviceTag),
|
|
346
|
+
identifiersForUpdateData,
|
|
335
347
|
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
348
|
+
{
|
|
349
|
+
returnValues: "ALL_NEW"
|
|
350
|
+
}
|
|
351
|
+
)
|
|
352
|
+
_izContext.logger.debug("updateItem:", updateItem);
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
)
|
|
357
|
+
)
|
|
346
358
|
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
359
|
+
function createObjInstanceFullFromParams(object, requestParams) {
|
|
360
|
+
let objInstanceFull = {
|
|
361
|
+
identifiers: {},
|
|
362
|
+
fields: {}
|
|
363
|
+
}
|
|
352
364
|
|
|
353
|
-
|
|
354
|
-
|
|
365
|
+
for (const field in object) {
|
|
366
|
+
if (requestParams.objInstanceFull.identifiers.hasOwnProperty(field)) {
|
|
367
|
+
Object.assign(objInstanceFull.identifiers, { [field]: requestParams.objInstanceFull.identifiers[field] })
|
|
368
|
+
}
|
|
355
369
|
|
|
356
|
-
|
|
357
|
-
|
|
370
|
+
if (requestParams.objInstanceFull.fields.hasOwnProperty(field)) {
|
|
371
|
+
Object.assign(objInstanceFull.fields, { [field]: requestParams.objInstanceFull.fields[field] })
|
|
372
|
+
}
|
|
373
|
+
}
|
|
358
374
|
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
let messageParams = {
|
|
362
|
-
Message: JSON.stringify(messageObject),
|
|
363
|
-
MessageAttributes: sns.createStringMessageAttributes(_izContext, messageAttributes),
|
|
364
|
-
TopicArn: outUpdateNodeCompleteTopic
|
|
365
|
-
}
|
|
375
|
+
return objInstanceFull
|
|
376
|
+
}
|
|
366
377
|
|
|
367
|
-
|
|
368
|
-
|
|
378
|
+
if (awaitingStepIds.length === 0) {
|
|
379
|
+
let messageObject = {
|
|
380
|
+
objType: objType,
|
|
381
|
+
objInstanceFull: createObjInstanceFullFromParams(updateItem, requestParams)
|
|
382
|
+
}
|
|
369
383
|
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
384
|
+
//(<additionalProperties>)
|
|
385
|
+
//(</additionalProperties>)
|
|
386
|
+
|
|
387
|
+
if (callingFlowConfig[callingFlowSharedLib.consts.CALLINGFLOWPROPERTIES_PROPERTYNAME]) {
|
|
388
|
+
_izContext.logger.debug("HAVE CALLING FLOW");
|
|
389
|
+
|
|
390
|
+
messageObject = callingFlowSharedLib.addPassBackPropertiesToSnsResponseMessageObject(callingFlowConfig, messageObject);
|
|
391
|
+
let messageAttributes = callingFlowSharedLib.addCallingFlowToSnsResponseMessageAttributes(callingFlowConfig, {});
|
|
392
|
+
|
|
393
|
+
_izContext.logger.debug("after create callingFlow", messageObject)
|
|
394
|
+
let outUpdateNodeCompleteTopic = await snsSharedLib.snsTopicArnByFlowSchema(_izContext, TOPIC_NAME_GENERATE_CODE.outUpdateNodeComplete);
|
|
395
|
+
let messageParams = {
|
|
396
|
+
Message: JSON.stringify(messageObject),
|
|
397
|
+
MessageAttributes: sns.createStringMessageAttributes(_izContext, messageAttributes),
|
|
398
|
+
TopicArn: outUpdateNodeCompleteTopic
|
|
373
399
|
}
|
|
374
|
-
|
|
375
|
-
|
|
400
|
+
|
|
401
|
+
_izContext.logger.debug("message params OutUpdateNodeComplete :::", messageParams);
|
|
402
|
+
await sns.publishAsync(_izContext, messageParams);
|
|
403
|
+
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
|
|
376
407
|
return {
|
|
377
408
|
returnValues: {
|
|
378
409
|
objType: objType,
|
|
@@ -196,6 +196,14 @@ async function externalLambdaIamRoleRelationships(_izContext, allRelSchemas) {
|
|
|
196
196
|
graphServiceNamesFromAllRelSchemas.map(graphServiceName =>
|
|
197
197
|
externalResourceName(RESOURCE_CLASSES.lambda, "GetRelationshipV2HdrInv", graphServiceName)
|
|
198
198
|
)
|
|
199
|
+
),
|
|
200
|
+
createIamRole(
|
|
201
|
+
{
|
|
202
|
+
[RESOURCE_CLASSES.sns]: [SNS_RESOURCE.publish]
|
|
203
|
+
},
|
|
204
|
+
graphServiceNamesFromAllRelSchemas.map(graphServiceName =>
|
|
205
|
+
externalResourceName(RESOURCE_CLASSES.sns, "ChangeRelationshipType_In", graphServiceName)
|
|
206
|
+
)
|
|
199
207
|
)
|
|
200
208
|
)
|
|
201
209
|
}
|
|
@@ -115,7 +115,6 @@ async function snsSubscriptionCreateRelationshipComplete(_izContext, allRelSchem
|
|
|
115
115
|
}
|
|
116
116
|
}
|
|
117
117
|
|
|
118
|
-
// topic not create yet will return error when initialSetup
|
|
119
118
|
// create topic for OutUpdateNodeComplete
|
|
120
119
|
async function snsSubscriptionOutUpdateNodeComplete(_izContext, allObjSchemas) {
|
|
121
120
|
let serviceTag = await getGraphServiceNameFromObjectSchema(_izContext, allObjSchemas)
|
|
@@ -127,6 +126,17 @@ async function snsSubscriptionOutUpdateNodeComplete(_izContext, allObjSchemas) {
|
|
|
127
126
|
}
|
|
128
127
|
}
|
|
129
128
|
|
|
129
|
+
// change relationship
|
|
130
|
+
async function snsSubScriptionUpdateRelationshipComplete(_izContext, allRelSchemas) {
|
|
131
|
+
let serviceTag = await getGraphServiceNameFromAllRelSchema(_izContext, allRelSchemas)
|
|
132
|
+
|
|
133
|
+
return {
|
|
134
|
+
serviceTag: serviceTag,
|
|
135
|
+
topicName: TOPIC_NAME_GRAPH_HANDLER.outChangeRelationship, // external service
|
|
136
|
+
sqsEndpoint: TOPIC_NAME_GENERATE_CODE.changeRelationshipComplete // in service
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
130
140
|
async function snsSubscriptionCreateNodeComplete(_izContext, allObjectSchemas) {
|
|
131
141
|
let serviceTag = await getGraphServiceNameFromObjectSchema(_izContext, allObjectSchemas)
|
|
132
142
|
|
|
@@ -21,20 +21,21 @@ const izara = require("@izara_project/izara-middleware");
|
|
|
21
21
|
const middleware = izara.middlewareHandler;
|
|
22
22
|
// const AWS = require('aws-sdk');
|
|
23
23
|
// const api = new AWS.ApiGatewayManagementApi({ endpoint: process.env.iz_webSocketEndpoint });
|
|
24
|
-
const dynamodbSharedLib = require('@izara_project/izara-core-library-dynamodb')
|
|
25
|
-
const callingFlowSharedLib = require('@izara_project/izara-core-library-calling-flow')
|
|
24
|
+
const dynamodbSharedLib = require('@izara_project/izara-core-library-dynamodb');
|
|
25
|
+
const callingFlowSharedLib = require('@izara_project/izara-core-library-calling-flow');
|
|
26
26
|
const hash = require('@izara_project/izara-shared-core').objectHash;
|
|
27
27
|
// const coreConsts = require("@izara_project/izara-core-library-core/src/Consts");
|
|
28
|
-
const consts = require('@izara_project/izara-middleware/src/MiddlewareCore/Consts')
|
|
29
|
-
const { postToConnection } = require('../../../libs/source/GenerateCodeLibs')
|
|
28
|
+
const consts = require('@izara_project/izara-middleware/src/MiddlewareCore/Consts');
|
|
29
|
+
const { postToConnection } = require('../../../libs/source/GenerateCodeLibs');
|
|
30
30
|
const <%- functionName %> = require('./<%- functionName %>_Main');
|
|
31
|
-
const { createFlowTypeConcat } = require("@izara_project/izara-core-library-service-schemas").utils
|
|
31
|
+
const { createFlowTypeConcat } = require("@izara_project/izara-core-library-service-schemas").utils;
|
|
32
|
+
const getObjectSchema = require('@izara_project/izara-core-library-service-schemas').getObjectSchema;
|
|
33
|
+
|
|
32
34
|
module.exports.main = middleware.wrap(async (event, context, callback) => {
|
|
33
35
|
|
|
34
36
|
event._izContext.logger.debug('Event:', event);
|
|
35
37
|
|
|
36
38
|
try {
|
|
37
|
-
|
|
38
39
|
if (event.requestContext) {
|
|
39
40
|
const route = event.requestContext.routeKey;
|
|
40
41
|
const connectionId = event.requestContext.connectionId;
|
|
@@ -52,7 +53,12 @@ module.exports.main = middleware.wrap(async (event, context, callback) => {
|
|
|
52
53
|
case '<%- route %>':
|
|
53
54
|
console.log("event in route webSocket", event);
|
|
54
55
|
let eventParams = JSON.parse(event.body)
|
|
55
|
-
|
|
56
|
+
|
|
57
|
+
//(<createIdentifiersFlow>)
|
|
58
|
+
let identifiers
|
|
59
|
+
//(</createIdentifiersFlow>)
|
|
60
|
+
|
|
61
|
+
let flowSchema = await getObjectSchema.getFlowSchemaS3WithCache(
|
|
56
62
|
event._izContext,
|
|
57
63
|
{
|
|
58
64
|
flowTag: "<%- route %>",
|
|
@@ -164,8 +164,9 @@ async function generateCodeWithTemplate(_izContext, objSchemaPath) {
|
|
|
164
164
|
const webSocketCompleteMainFunction = createWebSocketCompleteMainMainFunction(_izContext, saveFilePath);
|
|
165
165
|
const webSocketCompleteSqs = createWebSocketCompleteMainSqs(_izContext, allLocalFlowSchemas, saveFilePath)
|
|
166
166
|
const webSocketCompleteComponent = [...webSocketCompleteFunctionYaml, ...webSocketCompleteHandler, ...webSocketCompleteMainFunction, ...webSocketCompleteSqs]
|
|
167
|
+
const userUploadRecordTable = createUserUploadRecordTable(_izContext, saveFilePath)
|
|
167
168
|
|
|
168
|
-
const webSocketResource = [...webSocketTaskTable, ...webSocketConnectYaml, ...webSocketConnectHandler]
|
|
169
|
+
const webSocketResource = [...webSocketTaskTable, ...webSocketConnectYaml, ...webSocketConnectHandler, ...userUploadRecordTable]
|
|
169
170
|
if (allLocalFlowSchemas.records.length) {
|
|
170
171
|
createSourceParams.push(
|
|
171
172
|
...webSocketResource,
|
|
@@ -180,6 +181,7 @@ async function generateCodeWithTemplate(_izContext, objSchemaPath) {
|
|
|
180
181
|
for (const flowSchema of allLocalFlowSchemas.records) {
|
|
181
182
|
// console.log("flowSchema in Generate TemplateData", flowSchema);
|
|
182
183
|
const webSocketGenerateCodeLibs = createWebSocketGenerateCodeLibs(_izContext, flowSchema, saveFilePath)
|
|
184
|
+
|
|
183
185
|
createSourceParams.push(...webSocketGenerateCodeLibs)
|
|
184
186
|
if (!flowSchema.event.includes("s3")) {
|
|
185
187
|
const flowSchemaEndpointMainFunction = await createFlowSchemaEndpointMainFunction(_izContext, flowSchema, saveFilePath);
|
|
@@ -191,7 +193,6 @@ async function generateCodeWithTemplate(_izContext, objSchemaPath) {
|
|
|
191
193
|
if (event.includes("s3")) {
|
|
192
194
|
const reservedDataTable = createReservedDataMainTable(_izContext, saveFilePath);
|
|
193
195
|
const bucketS3 = createBucketS3(_izContext, flowSchema, saveFilePath)
|
|
194
|
-
const userUploadRecordTable = createUserUploadRecordTable(_izContext, saveFilePath)
|
|
195
196
|
|
|
196
197
|
const functionYamlCreateObjectWebSocket = createFunctionYamlCreateObjectWebSocket(_izContext, flowSchema, saveFilePath);
|
|
197
198
|
const handlerCreateObjectWebSocket = createHandlerCreateObjectWebSocket(_izContext, flowSchema, saveFilePath);
|
|
@@ -23,6 +23,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
23
23
|
const { middlewareHandler } = require("@izara_project/izara-middleware");
|
|
24
24
|
const recordHandlerSharedLib = require("@izara_project/izara-core-library-record-handler")
|
|
25
25
|
const Logger = require('@izara_project/izara-core-library-logger');
|
|
26
|
+
const callingFlowSharedLib = require('@izara_project/izara-core-library-calling-flow');
|
|
26
27
|
|
|
27
28
|
const { <%- functionName %>Main } =require('./<%- firstLetterUpperCase(functionName) %>_Main.js')
|
|
28
29
|
|
|
@@ -118,7 +118,9 @@ module.exports.registerCompleteMain = async (
|
|
|
118
118
|
await lambdaSharedLib.lambdaFunctionName(_izContext, "GetHdrInv"),
|
|
119
119
|
{
|
|
120
120
|
identifiers: await identifiersObject.identifiersFromIdentifiersConcat(_izContext, objType, requestParams.identifiersTask),
|
|
121
|
-
objectType: objType.objectType
|
|
121
|
+
objectType: objType.objectType,
|
|
122
|
+
//(<additionalParamsForGetData>)
|
|
123
|
+
//(</additionalParamsForGetData>)
|
|
122
124
|
}
|
|
123
125
|
)
|
|
124
126
|
await Promise.all(tasks.Items.map(async (task) => {
|
|
@@ -0,0 +1,123 @@
|
|
|
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
|
+
const path = require('path');
|
|
20
|
+
|
|
21
|
+
const { ACTIONS, HANDLER, STORAGE_TYPES } = require('@izara_project/izara-core-library-service-schemas/src/Consts');
|
|
22
|
+
|
|
23
|
+
const { firstLetterLowerCase: lowerCase, firstLetterUpperCase: upperCase } = require("../../../../../../../MainLibs/index.js").utils;
|
|
24
|
+
const {
|
|
25
|
+
createIamRole,
|
|
26
|
+
resourceNames,
|
|
27
|
+
RESOURCE_CLASSES,
|
|
28
|
+
SOURCE_PATH,
|
|
29
|
+
SAVE_FILE_NAME,
|
|
30
|
+
FUNCTION_NAME,
|
|
31
|
+
SNS_RESOURCE,
|
|
32
|
+
defaultIamRolePerAction,
|
|
33
|
+
awaitingMultipleStepsRole,
|
|
34
|
+
shortNameHandler,
|
|
35
|
+
SHORT_FUNCTION_NAME,
|
|
36
|
+
SOURCE_GENERATE_IAM_ROLE,
|
|
37
|
+
checkDynamoTypeRelationship,
|
|
38
|
+
createDynamoDbComponentByLinks,
|
|
39
|
+
DYNAMO_RESOURCE,
|
|
40
|
+
SQS_RESOURCE
|
|
41
|
+
} = require("../../../../../../../MainLibs/src/Consts.js");
|
|
42
|
+
|
|
43
|
+
const templatePath = path.join(__dirname, "./template.ejs")
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* receive objectSchema
|
|
47
|
+
* create data for updateRelationshipSchema
|
|
48
|
+
*
|
|
49
|
+
* @param {Object} objectSchema
|
|
50
|
+
* @return {{ templatePath, templateData, setting } }
|
|
51
|
+
*/
|
|
52
|
+
|
|
53
|
+
function data(_izContext, allObjectRelationships, srcPath) {
|
|
54
|
+
let createSourceArray = [];
|
|
55
|
+
|
|
56
|
+
const createSourceParam = createParamForCreateSource(allObjectRelationships, srcPath);
|
|
57
|
+
createSourceArray.push(createSourceParam);
|
|
58
|
+
// console.log("createSourceArrayInUpdaterelationShipSchemahdrSqs", createSourceArray)
|
|
59
|
+
return createSourceArray
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
function createParamForCreateSource(allObjectRelationships, srcPath) {
|
|
64
|
+
|
|
65
|
+
let handlerType = HANDLER.hdrApi
|
|
66
|
+
let functionName = FUNCTION_NAME.changeRel
|
|
67
|
+
let additionalResourcePermission = defaultIamRolePerAction();
|
|
68
|
+
|
|
69
|
+
additionalResourcePermission.push(awaitingMultipleStepsRole())
|
|
70
|
+
|
|
71
|
+
additionalResourcePermission.push(
|
|
72
|
+
createIamRole(
|
|
73
|
+
{
|
|
74
|
+
[RESOURCE_CLASSES.sqs]: [
|
|
75
|
+
SQS_RESOURCE.deleteMessage,
|
|
76
|
+
SQS_RESOURCE.getQueueAttributes,
|
|
77
|
+
SQS_RESOURCE.receiveMessage,
|
|
78
|
+
SQS_RESOURCE.sendMessage,
|
|
79
|
+
SQS_RESOURCE.getQueueUrl,
|
|
80
|
+
SQS_RESOURCE.deleteMessageBatch
|
|
81
|
+
],
|
|
82
|
+
},
|
|
83
|
+
[
|
|
84
|
+
resourceNames(RESOURCE_CLASSES.sqs, upperCase(functionName) + upperCase(HANDLER.hdrSqs)),
|
|
85
|
+
resourceNames(RESOURCE_CLASSES.sqs, upperCase(functionName) + upperCase(HANDLER.hdrSqs) + "DLQ"),
|
|
86
|
+
resourceNames(RESOURCE_CLASSES.sqs, upperCase(functionName) + upperCase(HANDLER.hdrDsq)),
|
|
87
|
+
resourceNames(RESOURCE_CLASSES.sqs, upperCase(functionName) + upperCase(HANDLER.hdrDsq) + "DLQ"),
|
|
88
|
+
]
|
|
89
|
+
),
|
|
90
|
+
createIamRole(
|
|
91
|
+
{
|
|
92
|
+
[RESOURCE_CLASSES.sns]: [SNS_RESOURCE.publish, SNS_RESOURCE.subscribe]
|
|
93
|
+
},
|
|
94
|
+
[
|
|
95
|
+
resourceNames(RESOURCE_CLASSES.sns, upperCase(FUNCTION_NAME.changeRelComplete) + "_Out"),
|
|
96
|
+
resourceNames(RESOURCE_CLASSES.sns, upperCase(functionName) + "_In"),
|
|
97
|
+
resourceNames(RESOURCE_CLASSES.sns, upperCase(functionName) + "_Out"),
|
|
98
|
+
]
|
|
99
|
+
)
|
|
100
|
+
)
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
return {
|
|
104
|
+
templatePath: templatePath,
|
|
105
|
+
templateData: {
|
|
106
|
+
functionName,
|
|
107
|
+
handlerType,
|
|
108
|
+
additionalResourcePermission,
|
|
109
|
+
resourceLocation: SOURCE_PATH.resourceLocationRelationshipPerAction,
|
|
110
|
+
functionNameConfig: upperCase(SHORT_FUNCTION_NAME.changeRel) + upperCase(shortNameHandler(handlerType)),
|
|
111
|
+
roleName: SOURCE_GENERATE_IAM_ROLE.RelationshipRole
|
|
112
|
+
},
|
|
113
|
+
setting: {
|
|
114
|
+
savePath: path.join(srcPath, SOURCE_PATH.appYaml),
|
|
115
|
+
saveFileName: SAVE_FILE_NAME.functionRelationshipYaml,
|
|
116
|
+
fileExtension: '.yml',
|
|
117
|
+
isAppend: true
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
module.exports = data;
|