@izara_project/izara-core-generate-service-code 1.0.67 → 1.0.68

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 (86) hide show
  1. package/.prettierrc +11 -0
  2. package/package.json +16 -12
  3. package/scripts/format-ejs.js +105 -0
  4. package/src/compile/compileProject.js +16 -1
  5. package/src/compile/loadSchemas.js +89 -4
  6. package/src/emit/crud/emitDynamicCrudFlowSchemas.js +1 -2
  7. package/src/emit/crud/templates/CreateEndpoint_Main.ejs +296 -105
  8. package/src/emit/crud/templates/DeleteEndpoint_Main.ejs +222 -144
  9. package/src/emit/crud/templates/FlowEndpointBeforeLogical_Main.ejs +22 -6
  10. package/src/emit/crud/templates/FlowEndpointComplete_Main.ejs +134 -43
  11. package/src/emit/crud/templates/FlowEndpoint_HdrWbs.ejs +51 -31
  12. package/src/emit/crud/templates/FlowHandler_HdrApi.ejs +53 -45
  13. package/src/emit/crud/templates/FlowHandler_HdrInv.ejs +28 -26
  14. package/src/emit/crud/templates/FlowHandler_HdrSqs.ejs +15 -11
  15. package/src/emit/crud/templates/FlowMain_Wbs.ejs +53 -38
  16. package/src/emit/crud/templates/GetEndpoint_Main.ejs +5 -2
  17. package/src/emit/crud/templates/GetRangeEndpoint_Main.ejs +2 -2
  18. package/src/emit/crud/templates/UpdateEndpoint_Main.ejs +402 -249
  19. package/src/emit/custom/customFlows.js +51 -21
  20. package/src/emit/custom/emitCustomFlowApplicationArtifacts.js +13 -18
  21. package/src/emit/custom/templates/FlowEndpoint_Main.ejs +48 -36
  22. package/src/emit/custom/templates/FlowStep_Main.ejs +7 -9
  23. package/src/emit/custom/templates/s3/ConfirmReserved_HdrSqs.ejs +59 -54
  24. package/src/emit/custom/templates/s3/ConfirmReserved_Main.ejs +33 -23
  25. package/src/emit/custom/templates/s3/CreateObject_HdrWbs.ejs +30 -23
  26. package/src/emit/custom/templates/s3/CreateObject_Main.ejs +56 -39
  27. package/src/emit/custom/templates/s3/CreatePreSignUrl_HdrSqs.ejs +56 -51
  28. package/src/emit/custom/templates/s3/CreatePreSignUrl_Main.ejs +112 -75
  29. package/src/emit/custom/templates/s3/FlowHandler_HdrS3.ejs +12 -7
  30. package/src/emit/custom/templates/s3/ProcessS3File_Main.ejs +11 -8
  31. package/src/emit/custom/templates/s3/ReservedLimit_HdrSqs.ejs +64 -55
  32. package/src/emit/custom/templates/s3/ReservedLimit_Main.ejs +74 -52
  33. package/src/emit/custom/templates/triggerCache/CheckTriggerCache_HdrSqs.ejs +58 -14
  34. package/src/emit/custom/templates/triggerCache/CheckTriggerCache_Main.ejs +12 -17
  35. package/src/emit/custom/templates/triggerCache/TriggerCacheComplete_Main.ejs +20 -13
  36. package/src/emit/custom/templates/triggerCache/TriggerCache_Main.ejs +4 -1
  37. package/src/emit/function/functionYamlArtifact.js +20 -0
  38. package/src/emit/rbac/emitDynamicRbacFlowSchemas.js +28 -15
  39. package/src/emit/rbac/emitRbacApplicationArtifacts.js +168 -69
  40. package/src/emit/rbac/templates/CreateTargetRole_HdrSqs.ejs +41 -18
  41. package/src/emit/rbac/templates/CreateTargetRole_Main.ejs +23 -3
  42. package/src/emit/rbac/templates/ListRbac_HdrApi.ejs +27 -5
  43. package/src/emit/rbac/templates/ListRbac_HdrSqs.ejs +41 -8
  44. package/src/emit/rbac/templates/ListRbac_Main.ejs +26 -6
  45. package/src/emit/rbac/templates/RbacMutation_Main.ejs +23 -3
  46. package/src/emit/rbac/templates/UserRbacFlow_HdrSqs.ejs +46 -0
  47. package/src/emit/rbac/templates/UserRbacFlow_Main.ejs +152 -33
  48. package/src/emit/rbac/templates/UserRoleMutation_Main.ejs +24 -4
  49. package/src/emit/relationship/emitDynamicRelationshipFlowSchemas.js +1 -2
  50. package/src/emit/relationship/templates/ChangeRelationshipComplete_Main.ejs +64 -37
  51. package/src/emit/relationship/templates/ChangeRelationship_Main.ejs +258 -142
  52. package/src/emit/relationship/templates/CreateRelationshipComplete_Main.ejs +68 -43
  53. package/src/emit/relationship/templates/CreateRelationship_Main.ejs +315 -171
  54. package/src/emit/relationship/templates/DeleteRelationshipComplete_Main.ejs +67 -41
  55. package/src/emit/relationship/templates/DeleteRelationship_Main.ejs +226 -115
  56. package/src/emit/relationship/templates/FlowHandler_HdrApi.ejs +41 -33
  57. package/src/emit/relationship/templates/FlowHandler_HdrDsq.ejs +15 -11
  58. package/src/emit/relationship/templates/FlowHandler_HdrInv.ejs +28 -26
  59. package/src/emit/relationship/templates/FlowHandler_HdrSqs.ejs +15 -11
  60. package/src/emit/relationship/templates/GetRelationshipComplete_Main.ejs +46 -26
  61. package/src/emit/relationship/templates/GetRelationship_Main.ejs +233 -126
  62. package/src/emit/relationship/templates/MoveRelationshipComplete_Main.ejs +72 -44
  63. package/src/emit/relationship/templates/MoveRelationship_Main.ejs +266 -150
  64. package/src/emit/relationship/templates/UpdateRelationshipComplete_Main.ejs +74 -45
  65. package/src/emit/relationship/templates/UpdateRelationship_Main.ejs +285 -152
  66. package/src/emit/resource/emitResourceArtifacts.js +107 -11
  67. package/src/emit/resource/templates/DynamoDBTable_Yaml.ejs +18 -18
  68. package/src/emit/resource/templates/FlowOut_Yaml.ejs +5 -5
  69. package/src/emit/resource/templates/GeneratedLambdaRoleServiceConfig.ejs +138 -0
  70. package/src/emit/resource/templates/ResourceBeforeLogicalYaml.ejs +44 -44
  71. package/src/emit/resource/templates/ResourceSqsYaml.ejs +36 -36
  72. package/src/emit/resource/templates/ResourceYaml.ejs +48 -48
  73. package/src/emit/resource/templates/S3Bucket_Yaml.ejs +19 -0
  74. package/src/emit/resource/templates/SharedResource_Yaml.ejs +11 -11
  75. package/src/emit/resource/templates/SystemDynamoDB_Yaml.ejs +105 -105
  76. package/src/generate.js +6 -2
  77. package/test/createTargetRoleHandler.test.js +63 -14
  78. package/test/customFlowApplicationArtifacts.test.js +48 -23
  79. package/test/dynamicCrudFlowSchemas.test.js +6 -6
  80. package/test/dynamicRbacFlowSchemas.test.js +8 -12
  81. package/test/dynamicRelationshipFlowSchemas.test.js +3 -3
  82. package/test/publicApi.test.js +10 -12
  83. package/test/resourceArtifacts.test.js +12 -2
  84. package/docs/test.png +0 -0
  85. package/src/emit/rbac/templates/UserRbacFlow_HdrInv.ejs +0 -10
  86. /package/docs/{test.mmd → TriggeredCacheFlow.mmd} +0 -0
@@ -1,9 +1,26 @@
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
+
1
18
  <% const fieldList = fields.join(', '); -%>
2
19
  import dynamodbSharedLib from '@izara_project/izara-core-library-dynamodb';
3
20
  import snsSharedLib from '@izara_project/izara-core-library-sns';
4
21
  import { sns } from '@izara_project/izara-core-library-external-request';
5
22
 
6
- export default async function Process<%- flowTag %>(_izContext, requestParams) {
23
+ export default async function <%- flowTag %>(_izContext, requestParams) {
7
24
  try {
8
25
  const { <%- fieldList %> } = requestParams;
9
26
  await dynamodbSharedLib.<%- method %>(
@@ -13,10 +30,13 @@ export default async function Process<%- flowTag %>(_izContext, requestParams) {
13
30
  );
14
31
  await sns.publishMessage(_izContext, {
15
32
  message: { returnResult: { <%- fieldList %> } },
16
- TopicArn: snsSharedLib.snsTopicArnByFlowSchema(_izContext, '<%- flowTag %>_Out')
33
+ TopicArn: snsSharedLib.snsTopicArnByFlowSchema(
34
+ _izContext,
35
+ '<%- flowTag %>_Out'
36
+ )
17
37
  });
18
38
  } catch (error) {
19
- _izContext.logger.error('[Rbac:Process<%- flowTag %>] error:', error);
39
+ _izContext.logger.error('[Rbac:<%- flowTag %>] error:', error);
20
40
  throw error;
21
41
  }
22
42
  }
@@ -0,0 +1,46 @@
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
+ import { middlewareHandler as middleware } from '@izara_project/izara-middleware';
19
+ import { recordHandlerSharedLib } from '@izara_project/izara-core-library-record-handler';
20
+ import callingFlowSharedLib from '@izara_project/izara-core-library-calling-flow';
21
+ import <%- flowTag %> from './<%- flowTag %>_Main.js';
22
+
23
+ middleware.setValidatorSchema(recordHandlerSharedLib.baseValidatorSchema());
24
+ export const main = middleware.wrap(async (event) =>
25
+ Promise.all(
26
+ event.Records.map(async (record) => {
27
+ await recordHandlerSharedLib.validateRecord(
28
+ record,
29
+ '<%- flowTag %>HdrSqs',
30
+ {},
31
+ null
32
+ );
33
+ return recordHandlerSharedLib.recordHandler(
34
+ record,
35
+ <%- flowTag %>,
36
+ '<%- flowTag %>HdrSqs',
37
+ [
38
+ record.body.Message,
39
+ callingFlowSharedLib.addCallingFlowToPassOnProperties(
40
+ record.body.Message
41
+ )
42
+ ]
43
+ );
44
+ })
45
+ )
46
+ );
@@ -1,44 +1,163 @@
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
+
1
18
  import dynamodbSharedLib from '@izara_project/izara-core-library-dynamodb';
2
19
  import { coreConsts } from '@izara_project/izara-core-library-core';
20
+ import { sns } from '@izara_project/izara-core-library-external-request';
21
+ import snsSharedLib from '@izara_project/izara-core-library-sns';
22
+
23
+ export default async function <%- flowTag %>(_izContext, requestParams = {}) {
24
+ const userId = _izContext.correlationIds.get(coreConsts.BASE_USER_ID);
25
+ const targetId = _izContext.correlationIds.get(coreConsts.TARGET_ID);
26
+ if (!userId || !targetId) {
27
+ throw new Error('Missing required request parameters: userId or targetId');
28
+ }
29
+
30
+ const { flowTypeConcat, inputParameterGroups } = requestParams;
31
+ if (!flowTypeConcat) {
32
+ throw new Error('Missing flowTypeConcat in requestParams');
33
+ }
3
34
 
4
- export default async function Process<%- flowTag %>(_izContext, requestParams) {
5
- try {
6
- const userId = _izContext.correlationIds.get(coreConsts.BASE_USER_ID);
7
- const targetId = _izContext.correlationIds.get(coreConsts.TARGET_ID);
8
- if (!userId && !targetId) throw new Error('Missing required request parameters: userId or targetId');
9
- const { flowTypeConcat, inputParameterGroups } = requestParams;
10
- if (!flowTypeConcat) throw new Error('Missing flowTypeConcat in requestParams');
11
- const userRoles = (await dynamodbSharedLib.query(
12
- _izContext,
13
- dynamodbSharedLib.tableName(_izContext, 'UserRoles'),
14
- { userId }
15
- )).Items || [];
16
- const targetRoles = userRoles.filter(role => role.roleIdKey?.startsWith(targetId + '_'));
17
- for (const role of targetRoles) {
18
- const permission = await dynamodbSharedLib.getItem(
19
- _izContext,
20
- dynamodbSharedLib.tableName(_izContext, 'RolePermissions'),
21
- { roleIdKey: role.roleIdKey, flowTypeConcat }
35
+ const userRolesResult = await dynamodbSharedLib.query(
36
+ _izContext,
37
+ dynamodbSharedLib.tableName(_izContext, 'UserRoles'),
38
+ { userId }
39
+ );
40
+
41
+ let userRoles = [];
42
+ if (Array.isArray(userRolesResult)) {
43
+ userRoles = userRolesResult;
44
+ } else if (userRolesResult && userRolesResult.Items) {
45
+ userRoles = userRolesResult.Items;
46
+ }
47
+
48
+ const targetIdPrefix = `${targetId}_`;
49
+ const targetRoles = [];
50
+ for (const role of userRoles) {
51
+ if (role && role.roleIdKey && role.roleIdKey.startsWith(targetIdPrefix)) {
52
+ targetRoles.push(role);
53
+ }
54
+ }
55
+
56
+ if (targetRoles.length === 0) {
57
+ await _publicMessageOut(_izContext, {
58
+ permission: false,
59
+ roleIdKey: ''
60
+ });
61
+ return;
62
+ }
63
+
64
+ const rolePermissionsTable = dynamodbSharedLib.tableName(
65
+ _izContext,
66
+ 'RolePermissions'
67
+ );
68
+ const rolePermissions = await Promise.all(
69
+ targetRoles.map(async (role) => {
70
+ return await dynamodbSharedLib.getItem(_izContext, rolePermissionsTable, {
71
+ roleIdKey: role.roleIdKey,
72
+ flowTypeConcat
73
+ });
74
+ })
75
+ );
76
+
77
+ let matched = null;
78
+ for (const permission of rolePermissions) {
79
+ if (permission && permission.permission === true) {
80
+ const isMatched = _matchesParameterGroups(
81
+ permission.parameterGroups,
82
+ inputParameterGroups
22
83
  );
23
- if (permission?.permission === true && matchesParameterGroups(permission.parameterGroups, inputParameterGroups)) {
24
- return { permission: true, roleIdKey: permission.roleIdKey };
84
+ if (isMatched) {
85
+ matched = permission;
86
+ break;
25
87
  }
26
88
  }
27
- return { permission: false, roleIdKey: '' };
28
- } catch (error) {
29
- _izContext.logger.error('error Process<%- flowTag %>:', error);
30
- throw error;
89
+ }
90
+
91
+ if (matched) {
92
+ await _publicMessageOut(_izContext, {
93
+ permission: true,
94
+ roleIdKey: matched.roleIdKey
95
+ });
96
+ } else {
97
+ await _publicMessageOut(_izContext, {
98
+ permission: false,
99
+ roleIdKey: ''
100
+ });
31
101
  }
32
102
  }
33
103
 
34
- function matchesParameterGroups(groups, input) {
35
- if (!groups || typeof groups !== 'object' || Array.isArray(groups) || Object.keys(groups).length === 0) return true;
36
- return Object.values(groups).some(group => Array.isArray(group) && group.every(check => {
37
- let value = input || {};
38
- for (const name of check.parameterNames || []) {
39
- if (!value || typeof value !== 'object' || !(name in value)) return false;
40
- value = value[name];
104
+ async function _publicMessageOut(_izContext, message) {
105
+ const topicOut = snsSharedLib.snsTopicArnByFlowSchema(
106
+ _izContext,
107
+ process.env.iz_flowTag + '_Out'
108
+ );
109
+
110
+ await sns.publishAsync(_izContext, {
111
+ topicArn: topicOut,
112
+ message: JSON.stringify(message)
113
+ });
114
+ }
115
+
116
+ function _matchesParameterGroups(groups, input) {
117
+ if (!groups || typeof groups !== 'object' || Array.isArray(groups)) {
118
+ return true;
119
+ }
120
+
121
+ const groupValues = Object.values(groups);
122
+ if (groupValues.length === 0) {
123
+ return true;
124
+ }
125
+
126
+ for (const group of groupValues) {
127
+ if (!Array.isArray(group)) {
128
+ continue;
129
+ }
130
+
131
+ let isGroupMatched = true;
132
+ for (const check of group) {
133
+ if (
134
+ !Array.isArray(check.parameterNames) ||
135
+ !Array.isArray(check.parameterValues)
136
+ ) {
137
+ isGroupMatched = false;
138
+ break;
139
+ }
140
+
141
+ let val = input || {};
142
+ for (const key of check.parameterNames) {
143
+ if (val && typeof val === 'object') {
144
+ val = val[key];
145
+ } else {
146
+ val = undefined;
147
+ break;
148
+ }
149
+ }
150
+
151
+ if (!check.parameterValues.includes(val)) {
152
+ isGroupMatched = false;
153
+ break;
154
+ }
41
155
  }
42
- return Array.isArray(check.parameterValues) && check.parameterValues.includes(value);
43
- }));
156
+
157
+ if (isGroupMatched) {
158
+ return true;
159
+ }
160
+ }
161
+
162
+ return false;
44
163
  }
@@ -1,11 +1,28 @@
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
+
1
18
  <%
2
19
  const itemType = operation === 'Put' ? 'Item' : 'Key';
3
20
  const roleUsersKey = operation === 'Put' ? 'userId, roleIdKey' : 'roleIdKey, userId';
4
- -%>import dynamodbSharedLib from '@izara_project/izara-core-library-dynamodb';
21
+ -%> import dynamodbSharedLib from '@izara_project/izara-core-library-dynamodb';
5
22
  import snsSharedLib from '@izara_project/izara-core-library-sns';
6
23
  import { sns } from '@izara_project/izara-core-library-external-request';
7
24
 
8
- export default async function Process<%- flowTag %>(_izContext, requestParams) {
25
+ export default async function <%- flowTag %>(_izContext, requestParams) {
9
26
  try {
10
27
  const { roleIdKey, userId } = requestParams;
11
28
  await dynamodbSharedLib.transactWriteItems(_izContext, [
@@ -24,10 +41,13 @@ export default async function Process<%- flowTag %>(_izContext, requestParams) {
24
41
  ]);
25
42
  await sns.publishMessage(_izContext, {
26
43
  message: { returnResult: { userId, roleIdKey } },
27
- TopicArn: snsSharedLib.snsTopicArnByFlowSchema(_izContext, '<%- flowTag %>_Out')
44
+ TopicArn: snsSharedLib.snsTopicArnByFlowSchema(
45
+ _izContext,
46
+ '<%- flowTag %>_Out'
47
+ )
28
48
  });
29
49
  } catch (error) {
30
- _izContext.logger.error('[Rbac:Process<%- flowTag %>] error:', error);
50
+ _izContext.logger.error('[Rbac:<%- flowTag %>] error:', error);
31
51
  throw error;
32
52
  }
33
53
  }
@@ -11,7 +11,7 @@ const ACTIONS = [
11
11
  const MESSAGE_ATTRIBUTES = ['userId', 'correlationId'];
12
12
 
13
13
  export const dynamicRelationshipFlowSchemaPaths = ACTIONS.map(
14
- action => `app/src/schemas/FlowSchemas/generateCode/${action}.js`
14
+ action => `app/src/schemas/FlowSchemas/generateCode/FlowRelationship/${action}.js`
15
15
  );
16
16
 
17
17
  export function emitDynamicRelationshipFlowSchemas() {
@@ -49,7 +49,6 @@ function createDynamicRelationshipFlow(action) {
49
49
 
50
50
  return {
51
51
  flowTag: action,
52
- isDynamicRelationshipType: true,
53
52
  initiateBy: 'system',
54
53
  handleObj: 'one',
55
54
  statusType: 'none',
@@ -15,22 +15,21 @@ You should have received a copy of the GNU Affero General Public License
15
15
  along with this program. If not, see <http://www.gnu.org/licenses/>.
16
16
  */
17
17
 
18
-
19
18
  import { objectHash as hash } from '@izara_project/izara-shared-core';
20
19
 
21
20
  import callingFlowSharedLib from '@izara_project/izara-core-library-calling-flow';
22
- import snsSharedLib from "@izara_project/izara-core-library-sns";
23
- import dynamodbSharedLib from "@izara_project/izara-core-library-dynamodb";
24
- import asyncFlowSharedLib from "@izara_project/izara-core-library-asynchronous-flow";
25
-
26
- import { sns } from "@izara_project/izara-core-library-external-request";
27
- import { utils, consts } from '@izara_project/izara-core-library-service-schemas';
21
+ import snsSharedLib from '@izara_project/izara-core-library-sns';
22
+ import dynamodbSharedLib from '@izara_project/izara-core-library-dynamodb';
23
+ import asyncFlowSharedLib from '@izara_project/izara-core-library-asynchronous-flow';
24
+
25
+ import { sns } from '@izara_project/izara-core-library-external-request';
26
+ import {
27
+ utils,
28
+ consts
29
+ } from '@izara_project/izara-core-library-service-schemas';
28
30
  const { createLinkTypeId } = utils;
29
31
 
30
- const {
31
- TOPIC_NAME_GENERATE_CODE,
32
- PREFIX
33
- } = consts;
32
+ const { TOPIC_NAME_GENERATE_CODE, PREFIX } = consts;
34
33
 
35
34
  //(<optionalRequire>)
36
35
  //(</optionalRequire>)
@@ -41,15 +40,15 @@ export default async function changeRelationshipComplete(
41
40
  status,
42
41
  errorsFound,
43
42
  graphServiceTag,
44
- passBackProperties = {},
43
+ passBackProperties = {}
45
44
  ) {
46
45
  try {
47
- _izContext.logger.debug("Function:ChangeRelationshipComplete", {
46
+ _izContext.logger.debug('Function:ChangeRelationshipComplete', {
48
47
  returnValue: returnValue,
49
48
  status: status,
50
49
  errorsFound: errorsFound,
51
50
  graphServiceTag: graphServiceTag,
52
- passBackProperties: passBackProperties,
51
+ passBackProperties: passBackProperties
53
52
  });
54
53
 
55
54
  // start create awaitingStepId
@@ -64,54 +63,83 @@ export default async function changeRelationshipComplete(
64
63
  let awaitingStepId = asyncFlowSharedLib.createAwaitingStepId(
65
64
  returnValue.parentFlowId, // hash id
66
65
  PREFIX.changeRel // prefix, use constant further
67
- )
68
-
66
+ );
69
67
 
70
68
  let createRelPendingObjects = await dynamodbSharedLib.query(
71
69
  _izContext,
72
- await dynamodbSharedLib.tableName(_izContext, "AwaitingMultipleSteps"),
70
+ await dynamodbSharedLib.tableName(_izContext, 'AwaitingMultipleSteps'),
73
71
  {
74
72
  awaitingStepId: awaitingStepId
75
73
  }
76
74
  );
77
- _izContext.logger.debug("record of createRelPendingObjects ::", createRelPendingObjects);
78
-
79
-
75
+ _izContext.logger.debug(
76
+ 'record of createRelPendingObjects ::',
77
+ createRelPendingObjects
78
+ );
80
79
 
81
80
  await Promise.all(
82
81
  createRelPendingObjects.Items.map(async ({ pendingStepId }) => {
83
- if (await asyncFlowSharedLib.checkAllAwaitingStepsFinished(
82
+ if (
83
+ await asyncFlowSharedLib.checkAllAwaitingStepsFinished(
84
84
  _izContext,
85
85
  pendingStepId, // task waiting
86
86
  awaitingStepId,
87
87
  errorsFound
88
- )) {
89
- _izContext.logger.debug("finished all awaitingStep");
88
+ )
89
+ ) {
90
+ _izContext.logger.debug('finished all awaitingStep');
90
91
 
91
92
  let changeRelCompleteMsg = {
92
93
  firstObject: returnValue.requestParams.firstObject,
93
94
  secondObject: returnValue.requestParams.secondObject,
94
95
  relType: returnValue.requestParams.relType,
95
- oldRelTypeAndDirection: returnValue.requestParams.oldRelTypeAndDirection,
96
+ oldRelTypeAndDirection:
97
+ returnValue.requestParams.oldRelTypeAndDirection,
96
98
  newRelType: returnValue.requestParams.newRelType,
97
99
  parentFlowId: returnValue.parentFlowId,
98
100
  status: status,
99
101
  errorsFound: errorsFound
100
102
  };
101
103
 
102
- changeRelCompleteMsg = callingFlowSharedLib.addParentPassBackPropertiesToSnsResponseMessageObject(passBackProperties, changeRelCompleteMsg);
103
- _izContext.logger.debug("After addCallingFlowToSnsResponseMessageObject", changeRelCompleteMsg);
104
-
105
- let messageAttributes = callingFlowSharedLib.addParentPassBackCallingFlowToSnsResponseMessageAttributes(passBackProperties, {});
106
- _izContext.logger.debug("After addCallingFlowToSnsResponseMessageAttributes", changeRelCompleteMsg);
104
+ changeRelCompleteMsg =
105
+ callingFlowSharedLib.addParentPassBackPropertiesToSnsResponseMessageObject(
106
+ passBackProperties,
107
+ changeRelCompleteMsg
108
+ );
109
+ _izContext.logger.debug(
110
+ 'After addCallingFlowToSnsResponseMessageObject',
111
+ changeRelCompleteMsg
112
+ );
113
+
114
+ let messageAttributes =
115
+ callingFlowSharedLib.addParentPassBackCallingFlowToSnsResponseMessageAttributes(
116
+ passBackProperties,
117
+ {}
118
+ );
119
+ _izContext.logger.debug(
120
+ 'After addCallingFlowToSnsResponseMessageAttributes',
121
+ changeRelCompleteMsg
122
+ );
107
123
 
108
124
  let sendMessageToOutChangeRelationshipComplete = {
109
125
  Message: JSON.stringify(changeRelCompleteMsg),
110
- MessageAttributes: sns.createStringMessageAttributes(_izContext, messageAttributes),
111
- TopicArn: await snsSharedLib.snsTopicArnByFlowSchema(_izContext, TOPIC_NAME_GENERATE_CODE.outChangeRelationshipComplete)
126
+ MessageAttributes: sns.createStringMessageAttributes(
127
+ _izContext,
128
+ messageAttributes
129
+ ),
130
+ TopicArn: snsSharedLib.snsTopicArnByFlowSchema(
131
+ _izContext,
132
+ TOPIC_NAME_GENERATE_CODE.outChangeRelationshipComplete
133
+ )
112
134
  };
113
- _izContext.logger.debug("Send message to OutChangeRelationshipComplete :::>", sendMessageToOutChangeRelationshipComplete);
114
- await sns.publishAsync(_izContext, sendMessageToOutChangeRelationshipComplete);
135
+ _izContext.logger.debug(
136
+ 'Send message to OutChangeRelationshipComplete :::>',
137
+ sendMessageToOutChangeRelationshipComplete
138
+ );
139
+ await sns.publishAsync(
140
+ _izContext,
141
+ sendMessageToOutChangeRelationshipComplete
142
+ );
115
143
 
116
144
  //(<afterCheckAwaitingStep>)
117
145
  //(</afterCheckAwaitingStep>)
@@ -134,10 +162,9 @@ export default async function changeRelationshipComplete(
134
162
  returnValue,
135
163
  status,
136
164
  errorsFound
137
- }
138
-
165
+ };
139
166
  } catch (err) {
140
- _izContext.logger.error('error createRelationshipComplete:', err)
141
- throw (err)
167
+ _izContext.logger.error('error createRelationshipComplete:', err);
168
+ throw err;
142
169
  }
143
170
  }