@izara_project/izara-core-generate-service-code 1.0.73 → 1.0.75

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.
Files changed (60) hide show
  1. package/package.json +1 -1
  2. package/src/emit/coreFunction/emitCoreFunctionArtifacts.js +3 -0
  3. package/src/emit/coreFunction/templates/InitialSetupConfig.ejs +100 -28
  4. package/src/emit/coreFunction/templates/InitialSetupRunner_uploadSchema.ejs +2 -0
  5. package/src/emit/coreFunction/templates/UploadSchema_Main.ejs +2 -0
  6. package/src/emit/crud/emitCrudApplicationArtifacts.js +2 -2
  7. package/src/emit/crud/emitDynamicCrudFlowSchemas.js +43 -2
  8. package/src/emit/crud/templates/CreateComplete_HdrSqs.ejs +99 -0
  9. package/src/emit/crud/templates/CreateComplete_Main.ejs +188 -0
  10. package/src/emit/crud/templates/DeleteComplete_HdrSqs.ejs +99 -0
  11. package/src/emit/crud/templates/DeleteComplete_Main.ejs +188 -0
  12. package/src/emit/crud/templates/FlowEndpointComplete_Main.ejs +1 -1
  13. package/src/emit/crud/templates/UpdateComplete_HdrSqs.ejs +99 -0
  14. package/src/emit/crud/templates/UpdateComplete_Main.ejs +188 -0
  15. package/src/emit/custom/customFlows.js +56 -0
  16. package/src/emit/custom/emitCustomFlowApplicationArtifacts.js +24 -9
  17. package/src/emit/custom/templates/FlowEndpoint_Main.ejs +1 -1
  18. package/src/emit/custom/templates/triggerCache/CheckTriggerCache_HdrSqs.ejs +2 -1
  19. package/src/emit/function/functionYamlArtifact.js +8 -3
  20. package/src/emit/relationship/emitDynamicRelationshipFlowSchemas.js +21 -1
  21. package/src/emit/relationship/emitRelationshipApplicationArtifacts.js +1 -1
  22. package/src/emit/relationship/templates/ChangeRelationshipComplete_HdrSqs.ejs +99 -0
  23. package/src/emit/relationship/templates/ChangeRelationshipComplete_Main.ejs +99 -100
  24. package/src/emit/relationship/templates/ChangeRelationship_Main.ejs +5 -14
  25. package/src/emit/relationship/templates/CreateRelationshipComplete_HdrSqs.ejs +99 -0
  26. package/src/emit/relationship/templates/CreateRelationshipComplete_Main.ejs +98 -99
  27. package/src/emit/relationship/templates/CreateRelationship_Main.ejs +7 -16
  28. package/src/emit/relationship/templates/DeleteRelationshipComplete_HdrSqs.ejs +99 -0
  29. package/src/emit/relationship/templates/DeleteRelationshipComplete_Main.ejs +93 -85
  30. package/src/emit/relationship/templates/DeleteRelationship_Main.ejs +6 -24
  31. package/src/emit/relationship/templates/GetRelationshipComplete_HdrSqs.ejs +99 -0
  32. package/src/emit/relationship/templates/GetRelationshipComplete_Main.ejs +10 -4
  33. package/src/emit/relationship/templates/GetRelationship_Main.ejs +2 -20
  34. package/src/emit/relationship/templates/MoveRelationshipComplete_HdrSqs.ejs +99 -0
  35. package/src/emit/relationship/templates/MoveRelationshipComplete_Main.ejs +101 -104
  36. package/src/emit/relationship/templates/MoveRelationship_Main.ejs +6 -15
  37. package/src/emit/relationship/templates/UpdateRelationshipComplete_HdrSqs.ejs +99 -0
  38. package/src/emit/relationship/templates/UpdateRelationshipComplete_Main.ejs +92 -110
  39. package/src/emit/relationship/templates/UpdateRelationship_Main.ejs +6 -15
  40. package/src/emit/resource/emitResourceArtifacts.js +25 -1
  41. package/src/emit/resource/templates/DynamoDBTable_Yaml.ejs +3 -0
  42. package/src/emit/shared/templates/FindData_Main.ejs +1 -1
  43. package/src/emit/shared/templates/FlowHandler_HdrApi.ejs +1 -1
  44. package/src/emit/shared/templates/FlowHandler_HdrDsq.ejs +2 -1
  45. package/src/emit/shared/templates/FlowHandler_HdrInv.ejs +1 -1
  46. package/src/emit/shared/templates/FlowHandler_HdrSqs.ejs +2 -1
  47. package/src/emit/system/emitSystemWebSocketArtifacts.js +54 -2
  48. package/src/emit/system/templates/RegisterComplete_HdrSqs.ejs +64 -0
  49. package/src/emit/system/templates/RegisterComplete_Main.ejs +154 -0
  50. package/src/emit/system/templates/RegisterComplete_Yaml.ejs +17 -0
  51. package/src/emit/system/templates/RegisterWbs_Yaml.ejs +7 -0
  52. package/src/emit/system/templates/Register_HdrWbs.ejs +56 -0
  53. package/src/emit/system/templates/Register_Main.ejs +148 -0
  54. package/src/emit/system/templates/WebSocketComplete_Yaml.ejs +2 -0
  55. package/test/crudApplicationArtifacts.test.js +22 -0
  56. package/test/customFlowApplicationArtifacts.test.js +147 -1
  57. package/test/functionYamlArtifact.test.js +5 -2
  58. package/test/publicApi.test.js +50 -0
  59. package/test/relationshipApplicationArtifacts.test.js +42 -8
  60. package/test/resourceArtifacts.test.js +54 -16
@@ -19,7 +19,7 @@ import { objectHash as hash } from '@izara_project/izara-shared-core';
19
19
 
20
20
  import callingFlowSharedLib from '@izara_project/izara-core-library-calling-flow';
21
21
  import snsSharedLib from '@izara_project/izara-core-library-sns';
22
- import dynamodbSharedLib from '@izara_project/izara-core-library-dynamodb';
22
+
23
23
  import asyncFlowSharedLib from '@izara_project/izara-core-library-asynchronous-flow';
24
24
 
25
25
  import { sns } from '@izara_project/izara-core-library-external-request';
@@ -36,123 +36,122 @@ const { TOPIC_NAME_GENERATE_CODE, PREFIX } = consts;
36
36
 
37
37
  export default async function createRelationshipComplete(
38
38
  _izContext,
39
- returnValue,
40
- status,
41
- errorsFound,
42
- graphServiceTag,
39
+ requestParams,
43
40
  passBackProperties = {}
44
41
  ) {
45
42
  try {
43
+ const {
44
+ returnValue,
45
+ parentFlowId,
46
+ status,
47
+ errorsFound,
48
+ graphServiceTag
49
+ } = requestParams;
50
+
46
51
  _izContext.logger.debug('Function:createRelationshipComplete', {
47
52
  returnValue: returnValue,
53
+ parentFlowId: parentFlowId,
48
54
  status: status,
49
55
  errorsFound: errorsFound,
50
56
  graphServiceTag: graphServiceTag,
51
57
  passBackProperties: passBackProperties
52
58
  });
53
59
 
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
- let awaitingStepId = asyncFlowSharedLib.createAwaitingStepId(
64
- returnValue.parentFlowId, // hash id
60
+ const awaitingStepId = asyncFlowSharedLib.createAwaitingStepId(
61
+ parentFlowId || returnValue?.parentFlowId, // hash id
65
62
  PREFIX.createRel // prefix, use constant further
66
63
  );
67
64
 
68
- let createRelPendingObjects = await dynamodbSharedLib.query(
69
- _izContext,
70
- await dynamodbSharedLib.tableName(_izContext, 'AwaitingMultipleSteps'),
65
+ const pending =
66
+ await asyncFlowSharedLib.findPendingStepAwaitingMultipleSteps(
67
+ _izContext,
68
+ awaitingStepId
69
+ );
70
+ _izContext.logger.debug('[CreateRelationshipComplete] awaiting step', {
71
+ awaitingStepId,
72
+ pending
73
+ });
74
+
75
+ if (!pending) {
76
+ _izContext.logger.warn(
77
+ `No pending step found for awaitingStepId: ${awaitingStepId}`
78
+ );
79
+ return { returnValue, status, errorsFound };
80
+ }
81
+
82
+ const result =
83
+ await asyncFlowSharedLib.checkAllAwaitingStepsFinishedWithReturnParams(
84
+ _izContext,
85
+ pending.pendingStepId,
86
+ awaitingStepId,
87
+ errorsFound
88
+ );
89
+ _izContext.logger.debug(
90
+ '[CreateRelationshipComplete] all awaiting steps result',
71
91
  {
72
- awaitingStepId: awaitingStepId
92
+ isComplete: result.isComplete,
93
+ awaitingStepId,
94
+ pendingStepId: pending.pendingStepId
73
95
  }
74
96
  );
75
- _izContext.logger.debug(
76
- 'record of createRelPendingObjects ::',
77
- createRelPendingObjects
78
- );
79
97
 
80
- await Promise.all(
81
- createRelPendingObjects.Items.map(async ({ pendingStepId }) => {
82
- if (
83
- await asyncFlowSharedLib.checkAllAwaitingStepsFinished(
84
- _izContext,
85
- pendingStepId, // task waiting
86
- awaitingStepId,
87
- errorsFound
88
- )
89
- ) {
90
- _izContext.logger.debug('finished all awaitingStep');
91
-
92
- let createCompleteMsg = {
93
- firstObject: returnValue.requestParams.firstObject,
94
- secondObject: returnValue.requestParams.secondObject,
95
- relType: returnValue.requestParams.relType,
96
- relationshipProperties:
97
- returnValue.requestParams.relationshipProperties,
98
- parentFlowId: returnValue.parentFlowId,
99
- status: status,
100
- errorsFound: errorsFound
101
- };
102
-
103
- createCompleteMsg =
104
- callingFlowSharedLib.addParentPassBackPropertiesToSnsResponseMessageObject(
105
- passBackProperties,
106
- createCompleteMsg
107
- );
108
- _izContext.logger.debug(
109
- 'After addCallingFlowToSnsResponseMessageObject',
110
- createCompleteMsg
111
- );
112
-
113
- let messageAttributes =
114
- callingFlowSharedLib.addParentPassBackCallingFlowToSnsResponseMessageAttributes(
115
- passBackProperties,
116
- {}
117
- );
118
- _izContext.logger.debug(
119
- 'After addCallingFlowToSnsResponseMessageAttributes',
120
- createCompleteMsg
121
- );
122
-
123
- let sendMessageToOutCreateRelationshipComplete = {
124
- Message: JSON.stringify(createCompleteMsg),
125
- MessageAttributes: sns.createStringMessageAttributes(
126
- _izContext,
127
- messageAttributes
128
- ),
129
- TopicArn: snsSharedLib.snsTopicArnByFlowSchema(
130
- _izContext,
131
- TOPIC_NAME_GENERATE_CODE.outCreateRelComplete
132
- )
133
- };
134
- _izContext.logger.debug(
135
- 'Send message to OutCreateRelationshipComplete :::>',
136
- sendMessageToOutCreateRelationshipComplete
137
- );
138
- await sns.publishAsync(
139
- _izContext,
140
- sendMessageToOutCreateRelationshipComplete
141
- );
142
-
143
- //(<afterCheckAwaitingStep>)
144
- //(</afterCheckAwaitingStep>)
145
- } // check pendingStepId finished
146
-
147
- // remove awaitingMultipleStep after finished
148
- await asyncFlowSharedLib.removeAwaitingMultipleStep(
149
- _izContext,
150
- awaitingStepId,
151
- pendingStepId,
152
- errorsFound
98
+ if (result.isComplete) {
99
+ _izContext.logger.debug('finished all awaitingStep');
100
+
101
+ let createCompleteMsg = {
102
+ firstObject: returnValue.requestParams.firstObject,
103
+ secondObject: returnValue.requestParams.secondObject,
104
+ relType: returnValue.requestParams.relType,
105
+ relationshipProperties:
106
+ returnValue.requestParams.relationshipProperties,
107
+ parentFlowId: parentFlowId || returnValue?.parentFlowId,
108
+ status: status,
109
+ errorsFound: errorsFound
110
+ };
111
+
112
+ createCompleteMsg =
113
+ callingFlowSharedLib.addParentPassBackPropertiesToSnsResponseMessageObject(
114
+ passBackProperties,
115
+ createCompleteMsg
153
116
  );
154
- }) // end per pendingStep
155
- );
117
+ _izContext.logger.debug(
118
+ 'After addCallingFlowToSnsResponseMessageObject',
119
+ createCompleteMsg
120
+ );
121
+
122
+ let messageAttributes =
123
+ callingFlowSharedLib.addParentPassBackCallingFlowToSnsResponseMessageAttributes(
124
+ passBackProperties,
125
+ {}
126
+ );
127
+ _izContext.logger.debug(
128
+ 'After addCallingFlowToSnsResponseMessageAttributes',
129
+ createCompleteMsg
130
+ );
131
+
132
+ let sendMessageToOutCreateRelationshipComplete = {
133
+ Message: JSON.stringify(createCompleteMsg),
134
+ MessageAttributes: sns.createStringMessageAttributes(
135
+ _izContext,
136
+ messageAttributes
137
+ ),
138
+ TopicArn: snsSharedLib.snsTopicArnByFlowSchema(
139
+ _izContext,
140
+ TOPIC_NAME_GENERATE_CODE.outCreateRelComplete
141
+ )
142
+ };
143
+ _izContext.logger.debug(
144
+ 'Send message to OutCreateRelationshipComplete :::>',
145
+ sendMessageToOutCreateRelationshipComplete
146
+ );
147
+ await sns.publishAsync(
148
+ _izContext,
149
+ sendMessageToOutCreateRelationshipComplete
150
+ );
151
+
152
+ //(<afterCheckAwaitingStep>)
153
+ //(</afterCheckAwaitingStep>)
154
+ } // check isComplete finished
156
155
 
157
156
  //(<afterCheckAllAwaitingStep>)
158
157
  //(</afterCheckAllAwaitingStep>)
@@ -83,7 +83,7 @@ export default async function createRelationship(
83
83
  relationshipDirection,
84
84
  relationshipProperties,
85
85
  deepPathConditional,
86
- settings
86
+ settings = {}
87
87
  //(<requestParamCreateRel>)
88
88
  //(</requestParamCreateRel>)
89
89
  } = requestParams;
@@ -376,15 +376,6 @@ export default async function createRelationship(
376
376
  return createRelCompleteMsg;
377
377
  }
378
378
 
379
- // before create awaitingStepId per graph storageResource
380
- const linkTypeId = createLinkTypeId(
381
- _izContext,
382
- firstObject.objType,
383
- secondObject.objType,
384
- relType,
385
- relationshipDirection
386
- );
387
-
388
379
  let usedGraphServiceTag = []; // collect used graph serviceTag, use to check duplicate graph serviceTag across graph serverTag
389
380
  let targetGraphStorageResources = []; // collect used graph storageResources, filtered duplicate graphServiceTag from graphServerTag out
390
381
  let awaitingStepIds = [];
@@ -398,12 +389,12 @@ export default async function createRelationship(
398
389
  targetGraphStorageResources.push(targetStorageResource);
399
390
 
400
391
  // awaitingStepId per graphServiceTag
401
- awaitingStepIds.push(
402
- asyncFlowSharedLib.createAwaitingStepId(
392
+ awaitingStepIds.push({
393
+ awaitingStepId: asyncFlowSharedLib.createAwaitingStepId(
403
394
  parentFlowId, // hash id
404
395
  PREFIX.createRel // prefix, use constant further
405
396
  )
406
- );
397
+ });
407
398
  }
408
399
 
409
400
  // if have storageResource.storageType === "dynamoDB" will create relationship here
@@ -453,12 +444,12 @@ export default async function createRelationship(
453
444
  // save awaiting
454
445
  await asyncFlowSharedLib.createAwaitingMultipleSteps(
455
446
  _izContext,
456
- awaitingStepIds, // awaitingStepIds
457
447
  asyncFlowSharedLib.createPendingStepId(
458
- // pendingStepId
459
448
  _izContext.uniqueRequestId, // hash id
460
449
  PREFIX.createRel // prefix, use constant further
461
- )
450
+ ),
451
+ awaitingStepIds,
452
+ {}
462
453
  );
463
454
 
464
455
  // prepare message body
@@ -0,0 +1,99 @@
1
+ import { middlewareHandler as middleware } from '@izara_project/izara-middleware';
2
+ import { recordHandlerSharedLib } from '@izara_project/izara-core-library-record-handler';
3
+ import Logger from '@izara_project/izara-core-library-logger';
4
+ import callingFlowSharedLib from '@izara_project/izara-core-library-calling-flow';
5
+ import DeleteRelationshipComplete from './DeleteRelationshipComplete_Main.js';
6
+
7
+ //(<optionalRequire>)
8
+ //(</optionalRequire>)
9
+
10
+ // validate event properties in body.Message of sqs event
11
+ let perRecordsValidatorSchema = {
12
+ type: 'object',
13
+ properties: {
14
+ returnValue: {
15
+ type: 'object'
16
+ },
17
+ parentFlowId: {
18
+ type: 'string'
19
+ },
20
+ status: {
21
+ type: 'string'
22
+ },
23
+ errorsFound: {
24
+ type: 'array'
25
+ },
26
+ graphServiceTag: {
27
+ type: 'string'
28
+ }
29
+ },
30
+ required: [
31
+ 'returnValue',
32
+ 'parentFlowId',
33
+ 'status',
34
+ 'errorsFound',
35
+ 'graphServiceTag'
36
+ ]
37
+ //(<validatorSchema>)
38
+ //(</validatorSchema>)
39
+ };
40
+
41
+ let messageAttributeValidatorSchema = null;
42
+ middleware.setValidatorSchema(recordHandlerSharedLib.baseValidatorSchema());
43
+
44
+ export const main = middleware.wrap(async (event, context) => {
45
+ try {
46
+ let recordPromises = [];
47
+
48
+ // loop each record and send to mainFunction
49
+ await Promise.all(
50
+ event.Records.map(async (record) => {
51
+ let passOnProperties = [];
52
+ record._izContext.logger.debug('record ReceiveMsgOutHdrSqs', record);
53
+
54
+ //validate message (and MessageAttributes)
55
+ await recordHandlerSharedLib.validateRecord(
56
+ record, // one record will send to mainFunction
57
+ 'DeleteRelationshipCompleteHdrSqs', // queue name that need to retry or send to dlq
58
+ perRecordsValidatorSchema, // schema for record.Message
59
+ messageAttributeValidatorSchema
60
+ );
61
+
62
+ // add argument (to invoke lambda) to passOnProperties[]
63
+ passOnProperties.push(record.body.Message);
64
+ passOnProperties.push(
65
+ callingFlowSharedLib.addPassBackPropertiesToPassOnProperties(
66
+ record.body.Message
67
+ )
68
+ );
69
+ //(<additionalParams>)
70
+ //(</additionalParams>)
71
+ record._izContext.logger.debug(
72
+ 'passOnProperties in handler',
73
+ passOnProperties
74
+ );
75
+
76
+ // call recordHandlerSharedLib.recordHandler with 3 parameters and return promise(resolve)
77
+ let recordPromise = recordHandlerSharedLib.recordHandler(
78
+ record, // one record will send to mainFunction
79
+ DeleteRelationshipComplete, // mainFunction that need to invoke.
80
+ 'DeleteRelationshipCompleteHdrSqs', // queue name that need to retry or send to dlq
81
+ passOnProperties // all parameters that mainFunction needed.
82
+ );
83
+ record._izContext.logger.debug('after recordPromise in handler');
84
+ recordPromises.push(recordPromise); // push promise to recordPromises
85
+ })
86
+ );
87
+ try {
88
+ await Promise.all(recordPromises);
89
+ return event.Records;
90
+ } catch {
91
+ Logger.debug(
92
+ 'Promise.all(recordPromises) in handler threw error (at least one record did no resolve)'
93
+ );
94
+ }
95
+ } catch (error) {
96
+ Logger.error('Unhandled Error, DeleteRelationshipComplete_HdrSqs: ', error);
97
+ throw error;
98
+ }
99
+ });
@@ -19,7 +19,7 @@ import { objectHash as hash } from '@izara_project/izara-shared-core';
19
19
 
20
20
  import callingFlowSharedLib from '@izara_project/izara-core-library-calling-flow';
21
21
  import snsSharedLib from '@izara_project/izara-core-library-sns';
22
- import dynamodbSharedLib from '@izara_project/izara-core-library-dynamodb';
22
+
23
23
  import asyncFlowSharedLib from '@izara_project/izara-core-library-asynchronous-flow';
24
24
 
25
25
  import { sns } from '@izara_project/izara-core-library-external-request';
@@ -36,109 +36,117 @@ const { TOPIC_NAME_GENERATE_CODE, PREFIX } = consts;
36
36
 
37
37
  export default async function deleteRelationshipComplete(
38
38
  _izContext,
39
- returnValue,
40
- status,
41
- errorsFound,
42
- graphServiceTag,
39
+ requestParams,
43
40
  passBackProperties = {}
44
41
  ) {
45
42
  try {
43
+ const {
44
+ returnValue,
45
+ parentFlowId,
46
+ status,
47
+ errorsFound,
48
+ graphServiceTag
49
+ } = requestParams;
50
+
46
51
  _izContext.logger.debug('Function:deleteRelationshipComplete', {
47
52
  returnValue: returnValue,
53
+ parentFlowId: parentFlowId,
48
54
  status: status,
49
55
  errorsFound: errorsFound,
50
56
  graphServiceTag: graphServiceTag,
51
57
  passBackProperties: passBackProperties
52
58
  });
53
59
 
54
- let awaitingStepId = asyncFlowSharedLib.createAwaitingStepId(
55
- returnValue.parentFlowId, // hash id
60
+ const awaitingStepId = asyncFlowSharedLib.createAwaitingStepId(
61
+ parentFlowId || returnValue?.parentFlowId, // hash id
56
62
  PREFIX.deleteRel // prefix, use constant further
57
63
  );
58
64
 
59
- let deleteRelPendingObjects = await dynamodbSharedLib.query(
60
- _izContext,
61
- await dynamodbSharedLib.tableName(_izContext, 'AwaitingMultipleSteps'),
65
+ const pending =
66
+ await asyncFlowSharedLib.findPendingStepAwaitingMultipleSteps(
67
+ _izContext,
68
+ awaitingStepId
69
+ );
70
+ _izContext.logger.debug('[DeleteRelationshipComplete] awaiting step', {
71
+ awaitingStepId,
72
+ pending
73
+ });
74
+
75
+ if (!pending) {
76
+ _izContext.logger.warn(
77
+ `No pending step found for awaitingStepId: ${awaitingStepId}`
78
+ );
79
+ return { returnValue, status, errorsFound };
80
+ }
81
+
82
+ const result =
83
+ await asyncFlowSharedLib.checkAllAwaitingStepsFinishedWithReturnParams(
84
+ _izContext,
85
+ pending.pendingStepId,
86
+ awaitingStepId,
87
+ errorsFound
88
+ );
89
+ _izContext.logger.debug(
90
+ '[DeleteRelationshipComplete] all awaiting steps result',
62
91
  {
63
- awaitingStepId: awaitingStepId
92
+ isComplete: result.isComplete,
93
+ awaitingStepId,
94
+ pendingStepId: pending.pendingStepId
64
95
  }
65
96
  );
66
- _izContext.logger.debug(
67
- 'record of deleteRelPendingObjects ::',
68
- deleteRelPendingObjects
69
- );
70
97
 
71
- await Promise.all(
72
- deleteRelPendingObjects.Items.map(async ({ pendingStepId }) => {
73
- if (
74
- await asyncFlowSharedLib.checkAllAwaitingStepsFinished(
75
- _izContext,
76
- pendingStepId, // task waiting
77
- awaitingStepId,
78
- errorsFound
79
- )
80
- ) {
81
- _izContext.logger.debug('finished all awaitingStep');
82
-
83
- let deleteRelComp = {
84
- firstObject: returnValue.requestParams.firstObject,
85
- secondObject: returnValue.requestParams.secondObject,
86
- relType: returnValue.requestParams.relType,
87
- parentFlowId: returnValue.parentFlowId,
88
- status: status,
89
- errorsFound: errorsFound
90
- };
91
-
92
- deleteRelComp =
93
- callingFlowSharedLib.addParentPassBackPropertiesToSnsResponseMessageObject(
94
- passBackProperties,
95
- deleteRelComp
96
- );
97
- _izContext.logger.debug(
98
- 'After addCallingFlowToSnsResponseMessageObject',
99
- deleteRelComp
100
- );
101
-
102
- let messageAttributes =
103
- callingFlowSharedLib.addParentPassBackCallingFlowToSnsResponseMessageAttributes(
104
- passBackProperties,
105
- {}
106
- );
107
- _izContext.logger.debug(
108
- 'After addCallingFlowToSnsResponseMessageAttributes',
109
- deleteRelComp
110
- );
111
-
112
- let sendMessageToOutDeleteRelationshipComplete = {
113
- Message: JSON.stringify(deleteRelComp),
114
- MessageAttributes: sns.createStringMessageAttributes(
115
- _izContext,
116
- messageAttributes
117
- ),
118
- TopicArn: snsSharedLib.snsTopicArnByFlowSchema(
119
- _izContext,
120
- TOPIC_NAME_GENERATE_CODE.outDeleteRelComplete
121
- )
122
- };
123
- _izContext.logger.debug(
124
- 'Send message to OutDeleteRelationshipComplete :::>',
125
- sendMessageToOutDeleteRelationshipComplete
126
- );
127
- await sns.publishAsync(
128
- _izContext,
129
- sendMessageToOutDeleteRelationshipComplete
130
- );
131
- } // check pendingStepId finished
132
-
133
- // remove awaitingMultipleStep after finished
134
- await asyncFlowSharedLib.removeAwaitingMultipleStep(
135
- _izContext,
136
- awaitingStepId,
137
- pendingStepId,
138
- errorsFound
98
+ if (result.isComplete) {
99
+ _izContext.logger.debug('finished all awaitingStep');
100
+
101
+ let deleteRelComp = {
102
+ firstObject: returnValue.requestParams.firstObject,
103
+ secondObject: returnValue.requestParams.secondObject,
104
+ relType: returnValue.requestParams.relType,
105
+ parentFlowId: parentFlowId || returnValue?.parentFlowId,
106
+ status: status,
107
+ errorsFound: errorsFound
108
+ };
109
+
110
+ deleteRelComp =
111
+ callingFlowSharedLib.addParentPassBackPropertiesToSnsResponseMessageObject(
112
+ passBackProperties,
113
+ deleteRelComp
139
114
  );
140
- }) // end per pendingStep
141
- );
115
+ _izContext.logger.debug(
116
+ 'After addCallingFlowToSnsResponseMessageObject',
117
+ deleteRelComp
118
+ );
119
+
120
+ let messageAttributes =
121
+ callingFlowSharedLib.addParentPassBackCallingFlowToSnsResponseMessageAttributes(
122
+ passBackProperties,
123
+ {}
124
+ );
125
+ _izContext.logger.debug(
126
+ 'After addCallingFlowToSnsResponseMessageAttributes',
127
+ deleteRelComp
128
+ );
129
+
130
+ let sendMessageToOutDeleteRelationshipComplete = {
131
+ Message: JSON.stringify(deleteRelComp),
132
+ MessageAttributes: sns.createStringMessageAttributes(
133
+ _izContext,
134
+ messageAttributes
135
+ ),
136
+ TopicArn: snsSharedLib.snsTopicArnByFlowSchema(
137
+ _izContext,
138
+ TOPIC_NAME_GENERATE_CODE.outDeleteRelComplete
139
+ )
140
+ };
141
+ _izContext.logger.debug(
142
+ 'Send message to OutDeleteRelationshipComplete :::>',
143
+ sendMessageToOutDeleteRelationshipComplete
144
+ );
145
+ await sns.publishAsync(
146
+ _izContext,
147
+ sendMessageToOutDeleteRelationshipComplete
148
+ );
149
+ } // check isComplete finished
142
150
 
143
151
  return {
144
152
  returnValue,
@@ -262,24 +262,6 @@ export default async function deleteRelationship(
262
262
  return deleteRelCompleteMsg;
263
263
  }
264
264
 
265
- // before create awaitingStepId per graph storageResource
266
- let linkTypeId;
267
- if (
268
- secondObject &&
269
- secondObject.hasOwnProperty('objType') &&
270
- Object.values(secondObject.objType).length > 0
271
- ) {
272
- linkTypeId = createLinkTypeId(
273
- _izContext,
274
- firstObject.objType,
275
- secondObject.objType,
276
- relType,
277
- relationshipDirection
278
- );
279
- } else {
280
- linkTypeId = hash({ objType: firstObject.objType, relType: relType });
281
- }
282
-
283
265
  let usedGraphServiceTag = []; // collect used graph serviceTag, use to check duplicate graph serviceTag across graph serverTag
284
266
  let targetGraphStorageResources = []; // collect used graph storageResources, filtered duplicate graphServiceTag from graphServerTag out
285
267
  let awaitingStepIds = [];
@@ -293,12 +275,12 @@ export default async function deleteRelationship(
293
275
  targetGraphStorageResources.push(targetStorageResource);
294
276
 
295
277
  // awaitingStepId per graphServiceTag
296
- awaitingStepIds.push(
297
- asyncFlowSharedLib.createAwaitingStepId(
278
+ awaitingStepIds.push({
279
+ awaitingStepId: asyncFlowSharedLib.createAwaitingStepId(
298
280
  parentFlowId, // hash id
299
281
  PREFIX.deleteRel // prefix, use constant further
300
282
  )
301
- );
283
+ });
302
284
  } else if (
303
285
  targetStorageResource.storageType === consts.STORAGE_TYPES.dynamoDB
304
286
  ) {
@@ -345,12 +327,12 @@ export default async function deleteRelationship(
345
327
  // save awaiting
346
328
  await asyncFlowSharedLib.createAwaitingMultipleSteps(
347
329
  _izContext,
348
- awaitingStepIds, // awaitingStepIds
349
330
  asyncFlowSharedLib.createPendingStepId(
350
- // pendingStepId
351
331
  _izContext.uniqueRequestId, // hash id
352
332
  PREFIX.deleteRel // prefix, use constant further
353
- )
333
+ ),
334
+ awaitingStepIds,
335
+ {}
354
336
  );
355
337
 
356
338
  // prepare message body