@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.
- package/.prettierrc +11 -0
- package/package.json +16 -12
- package/scripts/format-ejs.js +105 -0
- package/src/compile/compileProject.js +16 -1
- package/src/compile/loadSchemas.js +89 -4
- package/src/emit/crud/emitDynamicCrudFlowSchemas.js +1 -2
- package/src/emit/crud/templates/CreateEndpoint_Main.ejs +296 -105
- package/src/emit/crud/templates/DeleteEndpoint_Main.ejs +222 -144
- package/src/emit/crud/templates/FlowEndpointBeforeLogical_Main.ejs +22 -6
- package/src/emit/crud/templates/FlowEndpointComplete_Main.ejs +134 -43
- package/src/emit/crud/templates/FlowEndpoint_HdrWbs.ejs +51 -31
- package/src/emit/crud/templates/FlowHandler_HdrApi.ejs +53 -45
- package/src/emit/crud/templates/FlowHandler_HdrInv.ejs +28 -26
- package/src/emit/crud/templates/FlowHandler_HdrSqs.ejs +15 -11
- package/src/emit/crud/templates/FlowMain_Wbs.ejs +53 -38
- package/src/emit/crud/templates/GetEndpoint_Main.ejs +5 -2
- package/src/emit/crud/templates/GetRangeEndpoint_Main.ejs +2 -2
- package/src/emit/crud/templates/UpdateEndpoint_Main.ejs +402 -249
- package/src/emit/custom/customFlows.js +51 -21
- package/src/emit/custom/emitCustomFlowApplicationArtifacts.js +13 -18
- package/src/emit/custom/templates/FlowEndpoint_Main.ejs +48 -36
- package/src/emit/custom/templates/FlowStep_Main.ejs +7 -9
- package/src/emit/custom/templates/s3/ConfirmReserved_HdrSqs.ejs +59 -54
- package/src/emit/custom/templates/s3/ConfirmReserved_Main.ejs +33 -23
- package/src/emit/custom/templates/s3/CreateObject_HdrWbs.ejs +30 -23
- package/src/emit/custom/templates/s3/CreateObject_Main.ejs +56 -39
- package/src/emit/custom/templates/s3/CreatePreSignUrl_HdrSqs.ejs +56 -51
- package/src/emit/custom/templates/s3/CreatePreSignUrl_Main.ejs +112 -75
- package/src/emit/custom/templates/s3/FlowHandler_HdrS3.ejs +12 -7
- package/src/emit/custom/templates/s3/ProcessS3File_Main.ejs +11 -8
- package/src/emit/custom/templates/s3/ReservedLimit_HdrSqs.ejs +64 -55
- package/src/emit/custom/templates/s3/ReservedLimit_Main.ejs +74 -52
- package/src/emit/custom/templates/triggerCache/CheckTriggerCache_HdrSqs.ejs +58 -14
- package/src/emit/custom/templates/triggerCache/CheckTriggerCache_Main.ejs +12 -17
- package/src/emit/custom/templates/triggerCache/TriggerCacheComplete_Main.ejs +20 -13
- package/src/emit/custom/templates/triggerCache/TriggerCache_Main.ejs +4 -1
- package/src/emit/function/functionYamlArtifact.js +20 -0
- package/src/emit/rbac/emitDynamicRbacFlowSchemas.js +28 -15
- package/src/emit/rbac/emitRbacApplicationArtifacts.js +168 -69
- package/src/emit/rbac/templates/CreateTargetRole_HdrSqs.ejs +41 -18
- package/src/emit/rbac/templates/CreateTargetRole_Main.ejs +23 -3
- package/src/emit/rbac/templates/ListRbac_HdrApi.ejs +27 -5
- package/src/emit/rbac/templates/ListRbac_HdrSqs.ejs +41 -8
- package/src/emit/rbac/templates/ListRbac_Main.ejs +26 -6
- package/src/emit/rbac/templates/RbacMutation_Main.ejs +23 -3
- package/src/emit/rbac/templates/UserRbacFlow_HdrSqs.ejs +46 -0
- package/src/emit/rbac/templates/UserRbacFlow_Main.ejs +152 -33
- package/src/emit/rbac/templates/UserRoleMutation_Main.ejs +24 -4
- package/src/emit/relationship/emitDynamicRelationshipFlowSchemas.js +1 -2
- package/src/emit/relationship/templates/ChangeRelationshipComplete_Main.ejs +64 -37
- package/src/emit/relationship/templates/ChangeRelationship_Main.ejs +258 -142
- package/src/emit/relationship/templates/CreateRelationshipComplete_Main.ejs +68 -43
- package/src/emit/relationship/templates/CreateRelationship_Main.ejs +315 -171
- package/src/emit/relationship/templates/DeleteRelationshipComplete_Main.ejs +67 -41
- package/src/emit/relationship/templates/DeleteRelationship_Main.ejs +226 -115
- package/src/emit/relationship/templates/FlowHandler_HdrApi.ejs +41 -33
- package/src/emit/relationship/templates/FlowHandler_HdrDsq.ejs +15 -11
- package/src/emit/relationship/templates/FlowHandler_HdrInv.ejs +28 -26
- package/src/emit/relationship/templates/FlowHandler_HdrSqs.ejs +15 -11
- package/src/emit/relationship/templates/GetRelationshipComplete_Main.ejs +46 -26
- package/src/emit/relationship/templates/GetRelationship_Main.ejs +233 -126
- package/src/emit/relationship/templates/MoveRelationshipComplete_Main.ejs +72 -44
- package/src/emit/relationship/templates/MoveRelationship_Main.ejs +266 -150
- package/src/emit/relationship/templates/UpdateRelationshipComplete_Main.ejs +74 -45
- package/src/emit/relationship/templates/UpdateRelationship_Main.ejs +285 -152
- package/src/emit/resource/emitResourceArtifacts.js +107 -11
- package/src/emit/resource/templates/DynamoDBTable_Yaml.ejs +18 -18
- package/src/emit/resource/templates/FlowOut_Yaml.ejs +5 -5
- package/src/emit/resource/templates/GeneratedLambdaRoleServiceConfig.ejs +138 -0
- package/src/emit/resource/templates/ResourceBeforeLogicalYaml.ejs +44 -44
- package/src/emit/resource/templates/ResourceSqsYaml.ejs +36 -36
- package/src/emit/resource/templates/ResourceYaml.ejs +48 -48
- package/src/emit/resource/templates/S3Bucket_Yaml.ejs +19 -0
- package/src/emit/resource/templates/SharedResource_Yaml.ejs +11 -11
- package/src/emit/resource/templates/SystemDynamoDB_Yaml.ejs +105 -105
- package/src/generate.js +6 -2
- package/test/createTargetRoleHandler.test.js +63 -14
- package/test/customFlowApplicationArtifacts.test.js +48 -23
- package/test/dynamicCrudFlowSchemas.test.js +6 -6
- package/test/dynamicRbacFlowSchemas.test.js +8 -12
- package/test/dynamicRelationshipFlowSchemas.test.js +3 -3
- package/test/publicApi.test.js +10 -12
- package/test/resourceArtifacts.test.js +12 -2
- package/docs/test.png +0 -0
- package/src/emit/rbac/templates/UserRbacFlow_HdrInv.ejs +0 -10
- /package/docs/{test.mmd → TriggeredCacheFlow.mmd} +0 -0
|
@@ -15,39 +15,35 @@ 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
|
-
|
|
20
|
-
|
|
18
|
+
import {
|
|
19
|
+
objectHash as hash,
|
|
20
|
+
identifierUuid
|
|
21
|
+
} from '@izara_project/izara-shared-core';
|
|
21
22
|
|
|
22
23
|
import callingFlowSharedLib from '@izara_project/izara-core-library-calling-flow';
|
|
23
|
-
import lambdaSharedLib from
|
|
24
|
-
import snsSharedLib from
|
|
25
|
-
import asyncFlowSharedLib from
|
|
26
|
-
import dynamodbSharedLib from
|
|
24
|
+
import lambdaSharedLib from '@izara_project/izara-core-library-lambda';
|
|
25
|
+
import snsSharedLib from '@izara_project/izara-core-library-sns';
|
|
26
|
+
import asyncFlowSharedLib from '@izara_project/izara-core-library-asynchronous-flow';
|
|
27
|
+
import dynamodbSharedLib from '@izara_project/izara-core-library-dynamodb';
|
|
27
28
|
|
|
28
|
-
import { sns } from
|
|
29
|
+
import { sns } from '@izara_project/izara-core-library-external-request';
|
|
29
30
|
|
|
30
|
-
import {
|
|
31
|
+
import {
|
|
32
|
+
getObjectSchema,
|
|
33
|
+
utils,
|
|
34
|
+
serviceConfig,
|
|
35
|
+
consts,
|
|
36
|
+
identifiersObject
|
|
37
|
+
} from '@izara_project/izara-core-library-service-schemas';
|
|
31
38
|
|
|
32
|
-
const {
|
|
33
|
-
|
|
34
|
-
getObjSchemaS3WithHierarchy
|
|
35
|
-
} = getObjectSchema
|
|
39
|
+
const { getRelationshipSchemaWithCache, getObjSchemaS3WithHierarchy } =
|
|
40
|
+
getObjectSchema;
|
|
36
41
|
|
|
37
|
-
const {
|
|
38
|
-
createLinkTypeId
|
|
39
|
-
} = utils;
|
|
42
|
+
const { createLinkTypeId } = utils;
|
|
40
43
|
|
|
41
|
-
const {
|
|
42
|
-
getGraphServiceTagWithCache
|
|
43
|
-
} = serviceConfig;
|
|
44
|
-
|
|
45
|
-
const {
|
|
46
|
-
PREFIX,
|
|
47
|
-
TOPIC_NAME_GENERATE_CODE,
|
|
48
|
-
TOPIC_NAME_GRAPH_HANDLER
|
|
49
|
-
} = consts;
|
|
44
|
+
const { getGraphServiceTagWithCache } = serviceConfig;
|
|
50
45
|
|
|
46
|
+
const { PREFIX, TOPIC_NAME_GENERATE_CODE, TOPIC_NAME_GRAPH_HANDLER } = consts;
|
|
51
47
|
|
|
52
48
|
//(<optionalRequire>)
|
|
53
49
|
//(</optionalRequire>)
|
|
@@ -66,17 +62,20 @@ const {
|
|
|
66
62
|
export default async function updateRelationship(
|
|
67
63
|
_izContext,
|
|
68
64
|
requestParams,
|
|
69
|
-
callingFlowConfig = {}
|
|
65
|
+
callingFlowConfig = {}
|
|
70
66
|
//(<additionalParams>)
|
|
71
67
|
//(</additionalParams>)
|
|
72
68
|
) {
|
|
73
|
-
|
|
74
|
-
|
|
75
69
|
try {
|
|
76
70
|
_izContext.logger.debug('updateRelationship _izContext: ', _izContext);
|
|
77
|
-
_izContext.logger.debug(
|
|
78
|
-
|
|
79
|
-
|
|
71
|
+
_izContext.logger.debug(
|
|
72
|
+
'updateRelationship requestParams: ',
|
|
73
|
+
requestParams
|
|
74
|
+
);
|
|
75
|
+
_izContext.logger.debug(
|
|
76
|
+
'updateRelationship callingFlowConfig: ',
|
|
77
|
+
callingFlowConfig
|
|
78
|
+
);
|
|
80
79
|
|
|
81
80
|
const {
|
|
82
81
|
firstObject,
|
|
@@ -95,38 +94,59 @@ export default async function updateRelationship(
|
|
|
95
94
|
//(<beforeValidateUpdateRel>)
|
|
96
95
|
//(</beforeValidateUpdateRel>)
|
|
97
96
|
// validate object and identifiers
|
|
98
|
-
async function validateIdentifiersExists(
|
|
99
|
-
|
|
97
|
+
async function validateIdentifiersExists(
|
|
98
|
+
_izContext,
|
|
99
|
+
objType,
|
|
100
|
+
identifiersObject
|
|
101
|
+
) {
|
|
100
102
|
const objTypeString = `objType:{ serviceTag:${objType.serviceTag}, objectType:${objType.objectType} }`;
|
|
101
|
-
const objectSchema = await getObjSchemaS3WithHierarchy(
|
|
103
|
+
const objectSchema = await getObjSchemaS3WithHierarchy(
|
|
104
|
+
_izContext,
|
|
105
|
+
objType
|
|
106
|
+
);
|
|
102
107
|
|
|
103
108
|
if (!objectSchema) {
|
|
104
|
-
errorsFound.push(
|
|
109
|
+
errorsFound.push(
|
|
110
|
+
`validateIdentifiers, not found schema of ${objTypeString}`
|
|
111
|
+
);
|
|
105
112
|
}
|
|
106
113
|
|
|
107
114
|
for (const schemaIdentifier of objectSchema.identifiers) {
|
|
108
|
-
let identifierName =
|
|
115
|
+
let identifierName =
|
|
116
|
+
schemaIdentifier.fieldName || schemaIdentifier.name;
|
|
109
117
|
|
|
110
118
|
if (!identifiersObject.hasOwnProperty(identifierName)) {
|
|
111
|
-
errorsFound.push(
|
|
119
|
+
errorsFound.push(
|
|
120
|
+
`validateIdentifiers, ${objTypeString} property:${identifierName} not exists`
|
|
121
|
+
);
|
|
112
122
|
} else {
|
|
113
123
|
if (
|
|
114
|
-
typeof
|
|
115
|
-
typeof
|
|
124
|
+
typeof identifiersObject[identifierName] !== 'string' &&
|
|
125
|
+
typeof identifiersObject[identifierName] !== 'number'
|
|
116
126
|
) {
|
|
117
|
-
errorsFound.push(
|
|
127
|
+
errorsFound.push(
|
|
128
|
+
`validateIdentifiers, ${objTypeString} property:${identifierName} should be string or number`
|
|
129
|
+
);
|
|
118
130
|
}
|
|
119
131
|
}
|
|
120
132
|
}
|
|
121
|
-
}
|
|
133
|
+
}
|
|
122
134
|
|
|
123
135
|
if (firstObject && Object.values(firstObject).length > 0) {
|
|
124
|
-
await validateIdentifiersExists(
|
|
125
|
-
|
|
136
|
+
await validateIdentifiersExists(
|
|
137
|
+
_izContext,
|
|
138
|
+
firstObject.objType,
|
|
139
|
+
firstObject.identifiers
|
|
140
|
+
);
|
|
141
|
+
}
|
|
126
142
|
|
|
127
143
|
if (secondObject && Object.values(secondObject).length > 0) {
|
|
128
|
-
await validateIdentifiersExists(
|
|
129
|
-
|
|
144
|
+
await validateIdentifiersExists(
|
|
145
|
+
_izContext,
|
|
146
|
+
secondObject.objType,
|
|
147
|
+
secondObject.identifiers
|
|
148
|
+
);
|
|
149
|
+
}
|
|
130
150
|
// finished validate object and identifiers
|
|
131
151
|
|
|
132
152
|
//(<afterValidateUpdateRel>)
|
|
@@ -134,8 +154,11 @@ export default async function updateRelationship(
|
|
|
134
154
|
|
|
135
155
|
//(<beforeGetRelUpdateRel>)
|
|
136
156
|
//(</beforeGetRelUpdateRel>)
|
|
137
|
-
const relationshipSchema = await getRelationshipSchemaWithCache(
|
|
138
|
-
|
|
157
|
+
const relationshipSchema = await getRelationshipSchemaWithCache(
|
|
158
|
+
_izContext,
|
|
159
|
+
relType
|
|
160
|
+
);
|
|
161
|
+
_izContext.logger.debug('relationshipSchema: ', relationshipSchema);
|
|
139
162
|
|
|
140
163
|
let targetStorageResources = [];
|
|
141
164
|
|
|
@@ -144,88 +167,123 @@ export default async function updateRelationship(
|
|
|
144
167
|
let secondObjectHie;
|
|
145
168
|
|
|
146
169
|
if (firstObject && Object.values(firstObject).length > 0) {
|
|
147
|
-
firstObjectHie = await getObjectSchema.getObjSchemaS3WithHierarchy(
|
|
148
|
-
|
|
170
|
+
firstObjectHie = await getObjectSchema.getObjSchemaS3WithHierarchy(
|
|
171
|
+
_izContext,
|
|
172
|
+
firstObject.objType
|
|
173
|
+
);
|
|
174
|
+
}
|
|
149
175
|
|
|
150
176
|
if (secondObject && Object.values(secondObject).length > 0) {
|
|
151
|
-
secondObjectHie = await getObjectSchema.getObjSchemaS3WithHierarchy(
|
|
152
|
-
|
|
177
|
+
secondObjectHie = await getObjectSchema.getObjSchemaS3WithHierarchy(
|
|
178
|
+
_izContext,
|
|
179
|
+
secondObject.objType
|
|
180
|
+
);
|
|
181
|
+
}
|
|
153
182
|
|
|
154
183
|
if (firstObjectHie || firstObject || secondObjectHie || secondObject) {
|
|
155
184
|
// find targetStorageResources and validate each storageResources
|
|
156
185
|
await Promise.all(
|
|
157
|
-
relationshipSchema.links.map(
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
186
|
+
relationshipSchema.links.map(
|
|
187
|
+
async ({ from, to, storageResourceTags }) => {
|
|
188
|
+
const { serviceTag: fromServiceTag, objectType: fromObjectType } =
|
|
189
|
+
from.objType;
|
|
190
|
+
const { serviceTag: toServiceTag, objectType: toObjectType } =
|
|
191
|
+
to.objType;
|
|
192
|
+
|
|
193
|
+
const {
|
|
194
|
+
serviceTag: firstServiceTag,
|
|
195
|
+
objectType: firstObjectType
|
|
196
|
+
} = firstObjectHie.extendObjType || firstObject.objType;
|
|
197
|
+
const {
|
|
198
|
+
serviceTag: secondServiceTag,
|
|
199
|
+
objectType: secondObjectType
|
|
200
|
+
} = secondObjectHie.extendObjType || secondObject.objType;
|
|
201
|
+
|
|
202
|
+
// find exists link
|
|
203
|
+
if (
|
|
204
|
+
(firstServiceTag === fromServiceTag &&
|
|
205
|
+
firstObjectType === fromObjectType &&
|
|
206
|
+
secondServiceTag === toServiceTag &&
|
|
207
|
+
secondObjectType === toObjectType) ||
|
|
208
|
+
(firstServiceTag === toServiceTag &&
|
|
209
|
+
firstObjectType === toObjectType &&
|
|
210
|
+
secondServiceTag === fromServiceTag &&
|
|
211
|
+
secondObjectType === fromObjectType)
|
|
212
|
+
) {
|
|
213
|
+
// check founded storageResource of link and collect used storageResources
|
|
214
|
+
await Promise.all(
|
|
215
|
+
storageResourceTags.map(async (storageResourceTag) => {
|
|
216
|
+
const usedStorageResource =
|
|
217
|
+
relationshipSchema.storageResources[storageResourceTag];
|
|
218
|
+
|
|
219
|
+
if (
|
|
220
|
+
usedStorageResource.storageType ===
|
|
221
|
+
consts.STORAGE_TYPES.graph
|
|
222
|
+
) {
|
|
223
|
+
const graphServiceTag = await getGraphServiceTagWithCache(
|
|
224
|
+
_izContext,
|
|
225
|
+
usedStorageResource.graphServerTag
|
|
226
|
+
);
|
|
227
|
+
if (!graphServiceTag) {
|
|
228
|
+
errorsFound.push(
|
|
229
|
+
`storageResourceTag:${storageResourceTag} invalid, not found graph serviceTag from graphServerTag:${usedStorageResource.graphServerTag}`
|
|
230
|
+
);
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
targetStorageResources.push({
|
|
234
|
+
...usedStorageResource,
|
|
235
|
+
graphServiceTag: graphServiceTag
|
|
236
|
+
});
|
|
237
|
+
} else {
|
|
238
|
+
targetStorageResources.push(usedStorageResource);
|
|
239
|
+
}
|
|
240
|
+
})
|
|
241
|
+
);
|
|
242
|
+
}
|
|
194
243
|
}
|
|
195
|
-
|
|
244
|
+
)
|
|
196
245
|
);
|
|
197
246
|
}
|
|
198
247
|
//(<afterGetRelUpdateRel>)
|
|
199
248
|
//(</afterGetRelUpdateRel>)
|
|
200
|
-
_izContext.logger.debug(
|
|
249
|
+
_izContext.logger.debug(
|
|
250
|
+
'targetStorageResources: ',
|
|
251
|
+
targetStorageResources
|
|
252
|
+
);
|
|
201
253
|
|
|
202
254
|
if (!targetStorageResources.length) {
|
|
203
255
|
errorsFound.push(`Not found link from relationship schema`);
|
|
204
256
|
}
|
|
205
257
|
|
|
206
|
-
|
|
207
258
|
// validate canUpdate properties relationship
|
|
208
|
-
for (const [propKey, propValue] of Object.entries(
|
|
209
|
-
|
|
210
|
-
|
|
259
|
+
for (const [propKey, propValue] of Object.entries(
|
|
260
|
+
relationshipProperties
|
|
261
|
+
)) {
|
|
262
|
+
_izContext.logger.debug('propKey: ', propKey);
|
|
263
|
+
_izContext.logger.debug('propValue: ', propValue);
|
|
211
264
|
|
|
212
265
|
if (relationshipSchema.fieldNames[propKey]) {
|
|
213
|
-
if (relationshipSchema.fieldNames[propKey].updateBy ===
|
|
266
|
+
if (relationshipSchema.fieldNames[propKey].updateBy === 'user') {
|
|
214
267
|
if (callingFlowConfig) {
|
|
215
|
-
if (
|
|
216
|
-
|
|
268
|
+
if (
|
|
269
|
+
callingFlowConfig.callingFlow !==
|
|
270
|
+
'ImportDataTestExternalUpdateRelationshipHdrSqs'
|
|
271
|
+
) {
|
|
272
|
+
errorsFound.push(
|
|
273
|
+
`property:${propKey} can update user but it's not user process with importData`
|
|
274
|
+
);
|
|
217
275
|
}
|
|
218
276
|
}
|
|
219
277
|
}
|
|
220
278
|
} else {
|
|
221
|
-
errorsFound.push(
|
|
279
|
+
errorsFound.push(
|
|
280
|
+
`property:${propKey} not exists in relationshipSchema`
|
|
281
|
+
);
|
|
222
282
|
}
|
|
223
283
|
}
|
|
224
284
|
|
|
225
|
-
|
|
226
285
|
// if found errors will stop processing
|
|
227
286
|
if (errorsFound.length) {
|
|
228
|
-
|
|
229
287
|
let updateCompleteMsg = {
|
|
230
288
|
firstObject: firstObject,
|
|
231
289
|
secondObject: secondObject,
|
|
@@ -234,41 +292,68 @@ export default async function updateRelationship(
|
|
|
234
292
|
relationshipDirection,
|
|
235
293
|
status: 'error',
|
|
236
294
|
errorsFound: errorsFound,
|
|
237
|
-
parentFlowId: parentFlowId
|
|
295
|
+
parentFlowId: parentFlowId
|
|
238
296
|
//(<inUpdateCompleteMsgUpdateRel>)
|
|
239
297
|
//(</inUpdateCompleteMsgUpdateRel>)
|
|
240
298
|
};
|
|
241
299
|
|
|
242
300
|
// if have callingFlow will send to message complete
|
|
243
|
-
if (
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
301
|
+
if (
|
|
302
|
+
callingFlowConfig[
|
|
303
|
+
callingFlowSharedLib.consts.CALLINGFLOW_PROPERTYNAME
|
|
304
|
+
]
|
|
305
|
+
) {
|
|
306
|
+
_izContext.logger.debug('HAVE CallingFlow');
|
|
307
|
+
|
|
308
|
+
updateCompleteMsg =
|
|
309
|
+
callingFlowSharedLib.addPassBackPropertiesToSnsResponseMessageObject(
|
|
310
|
+
callingFlowConfig,
|
|
311
|
+
updateCompleteMsg
|
|
312
|
+
);
|
|
313
|
+
let messageAttributes =
|
|
314
|
+
callingFlowSharedLib.addCallingFlowToSnsResponseMessageAttributes(
|
|
315
|
+
callingFlowConfig,
|
|
316
|
+
{}
|
|
317
|
+
);
|
|
248
318
|
|
|
249
319
|
let messageParams = {
|
|
250
320
|
Message: JSON.stringify(updateCompleteMsg),
|
|
251
|
-
MessageAttributes: sns.createStringMessageAttributes(
|
|
252
|
-
|
|
321
|
+
MessageAttributes: sns.createStringMessageAttributes(
|
|
322
|
+
_izContext,
|
|
323
|
+
messageAttributes
|
|
324
|
+
),
|
|
325
|
+
TopicArn: snsSharedLib.snsTopicArnByFlowSchema(
|
|
326
|
+
_izContext,
|
|
327
|
+
TOPIC_NAME_GENERATE_CODE.outUpdateRelComplete
|
|
328
|
+
)
|
|
253
329
|
};
|
|
254
330
|
|
|
255
|
-
_izContext.logger.debug(
|
|
331
|
+
_izContext.logger.debug(
|
|
332
|
+
'messageParams OutUpdateRelationshipComplete ::::::: ',
|
|
333
|
+
messageParams
|
|
334
|
+
);
|
|
256
335
|
await sns.publishAsync(_izContext, messageParams);
|
|
257
336
|
}
|
|
258
337
|
|
|
259
338
|
return updateCompleteMsg;
|
|
260
339
|
}
|
|
261
340
|
|
|
262
|
-
|
|
263
341
|
// before create awaitingStepId per graph storageResource
|
|
264
|
-
const linkTypeId = createLinkTypeId(
|
|
342
|
+
const linkTypeId = createLinkTypeId(
|
|
343
|
+
_izContext,
|
|
344
|
+
firstObject.objType,
|
|
345
|
+
secondObject.objType,
|
|
346
|
+
relType,
|
|
347
|
+
relationshipDirection
|
|
348
|
+
);
|
|
265
349
|
|
|
266
350
|
let usedGraphServiceTag = []; // collect used graph serviceName, use to check duplicate graph serviceName across graph serverTag
|
|
267
351
|
let targetGraphStorageResources = []; // collect used graph storageResources, filtered duplicate graphServiceTag from graphServerTag out
|
|
268
352
|
let awaitingStepIds = [];
|
|
269
353
|
|
|
270
354
|
for (const targetStorageResource of targetStorageResources) {
|
|
271
|
-
if (
|
|
355
|
+
if (
|
|
356
|
+
targetStorageResource.storageType === consts.STORAGE_TYPES.graph &&
|
|
272
357
|
!usedGraphServiceTag.includes(targetStorageResource.graphServiceTag)
|
|
273
358
|
) {
|
|
274
359
|
usedGraphServiceTag.push(targetStorageResource.graphServiceTag);
|
|
@@ -281,30 +366,44 @@ export default async function updateRelationship(
|
|
|
281
366
|
PREFIX.updateRel // prefix, use constant further
|
|
282
367
|
)
|
|
283
368
|
);
|
|
284
|
-
} else if (
|
|
369
|
+
} else if (
|
|
370
|
+
storageResource.storageType === consts.STORAGE_TYPES.dynamoDB
|
|
371
|
+
) {
|
|
285
372
|
let tableNameFrom = `${firstObject.objType.serviceTag}_${firstObject.objType.objectType}__${relType.relationshipTag}__${secondObject.objType.serviceTag}_${secondObject.objType.objectType}`;
|
|
286
373
|
let tableNameTo = `${secondObject.objType.serviceTag}_${secondObject.objType.objectType}__${relType.relationshipTag}__${firstObject.objType.serviceTag}_${firstObject.objType.objectType}`;
|
|
287
374
|
|
|
288
|
-
let identifiersConcatFirstObject =
|
|
289
|
-
|
|
375
|
+
let identifiersConcatFirstObject =
|
|
376
|
+
await identifiersObject.identifiersConcatFromIdentifiers(
|
|
377
|
+
_izContext,
|
|
378
|
+
firstObject.objType,
|
|
379
|
+
firstObject.identifiers
|
|
380
|
+
);
|
|
381
|
+
let identifiersConcatSecondObject =
|
|
382
|
+
await identifiersObject.identifiersConcatFromIdentifiers(
|
|
383
|
+
_izContext,
|
|
384
|
+
secondObject.objType,
|
|
385
|
+
secondObject.identifiers
|
|
386
|
+
);
|
|
290
387
|
const firstObjectIdentifiersConcat = `${firstObject.objType.serviceTag}_${firstObject.objType.objectType}__identifiersConcat`;
|
|
291
388
|
const secondObjectIdentifiersConcat = `${secondObject.objType.serviceTag}_${secondObject.objType.objectType}__identifiersConcat`;
|
|
292
389
|
|
|
293
|
-
await dynamodbSharedLib.updateItem(
|
|
390
|
+
await dynamodbSharedLib.updateItem(
|
|
391
|
+
_izContext,
|
|
294
392
|
await dynamodbSharedLib.tableName(_izContext, tableNameFrom),
|
|
295
393
|
{
|
|
296
394
|
[identifiersConcatFirstObject]: firstObjectIdentifiersConcat,
|
|
297
395
|
[identifiersConcatSecondObject]: secondObjectIdentifiersConcat
|
|
298
396
|
}
|
|
299
|
-
)
|
|
397
|
+
);
|
|
300
398
|
|
|
301
|
-
await dynamodbSharedLib.updateItem(
|
|
399
|
+
await dynamodbSharedLib.updateItem(
|
|
400
|
+
_izContext,
|
|
302
401
|
await dynamodbSharedLib.tableName(_izContext, tableNameTo),
|
|
303
402
|
{
|
|
304
403
|
[identifiersConcatSecondObject]: secondObjectIdentifiersConcat,
|
|
305
404
|
[identifiersConcatFirstObject]: firstObjectIdentifiersConcat
|
|
306
405
|
}
|
|
307
|
-
)
|
|
406
|
+
);
|
|
308
407
|
}
|
|
309
408
|
}
|
|
310
409
|
|
|
@@ -313,7 +412,8 @@ export default async function updateRelationship(
|
|
|
313
412
|
await asyncFlowSharedLib.createAwaitingMultipleSteps(
|
|
314
413
|
_izContext,
|
|
315
414
|
awaitingStepIds, // awaitingStepIds
|
|
316
|
-
asyncFlowSharedLib.createPendingStepId(
|
|
415
|
+
asyncFlowSharedLib.createPendingStepId(
|
|
416
|
+
// pendingStepId
|
|
317
417
|
_izContext.uniqueRequestId, // hash id
|
|
318
418
|
PREFIX.updateRel // prefix, use constant further
|
|
319
419
|
)
|
|
@@ -330,41 +430,54 @@ export default async function updateRelationship(
|
|
|
330
430
|
parentFlowId
|
|
331
431
|
//(<inUpdateRelMessageBodyUpdateRel>)
|
|
332
432
|
//(</inUpdateRelMessageBodyUpdateRel>)
|
|
333
|
-
}
|
|
433
|
+
};
|
|
334
434
|
_izContext.logger.debug('updateRelMessageBody: ', updateRelMessageBody);
|
|
335
435
|
|
|
336
436
|
await Promise.all(
|
|
337
437
|
targetGraphStorageResources.map(async (storageResource) => {
|
|
338
438
|
if (storageResource.storageType === consts.STORAGE_TYPES.graph) {
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
439
|
+
updateRelMessageBody =
|
|
440
|
+
callingFlowSharedLib.addCallingFlowToSnsRequestMessageObject(
|
|
441
|
+
updateRelMessageBody,
|
|
442
|
+
callingFlowSharedLib.addParentCallingFlowConfig(
|
|
443
|
+
callingFlowConfig, // receive parent callingFlowConfig.
|
|
444
|
+
callingFlowSharedLib.createCallingFlowConfig(
|
|
445
|
+
// callingFlow own service
|
|
446
|
+
//(<callingFlowProperties>)
|
|
447
|
+
await lambdaSharedLib.lambdaFunctionName(
|
|
448
|
+
_izContext,
|
|
449
|
+
TOPIC_NAME_GENERATE_CODE.updateRelComplete
|
|
450
|
+
),
|
|
451
|
+
//(</callingFlowProperties>)
|
|
452
|
+
{
|
|
453
|
+
graphServiceTag: storageResource.graphServiceTag
|
|
454
|
+
}
|
|
455
|
+
)
|
|
351
456
|
)
|
|
352
|
-
)
|
|
457
|
+
);
|
|
458
|
+
_izContext.logger.debug(
|
|
459
|
+
'messageObject before send message:',
|
|
460
|
+
updateRelMessageBody
|
|
353
461
|
);
|
|
354
|
-
_izContext.logger.debug("messageObject before send message:", updateRelMessageBody)
|
|
355
462
|
|
|
356
463
|
let messageToInUpdateRelationship = {
|
|
357
464
|
Message: JSON.stringify(updateRelMessageBody),
|
|
358
|
-
TopicArn:
|
|
465
|
+
TopicArn: snsSharedLib.snsTopicArnByFlowSchema(
|
|
466
|
+
_izContext,
|
|
467
|
+
TOPIC_NAME_GRAPH_HANDLER.inUpdateRel,
|
|
468
|
+
storageResource.graphServiceTag
|
|
469
|
+
)
|
|
359
470
|
};
|
|
360
|
-
_izContext.logger.debug(
|
|
471
|
+
_izContext.logger.debug(
|
|
472
|
+
'RequestParams before send to sqs messageToInUpdateRelationship ::::::: ',
|
|
473
|
+
messageToInUpdateRelationship
|
|
474
|
+
);
|
|
361
475
|
await sns.publishAsync(_izContext, messageToInUpdateRelationship);
|
|
362
476
|
}
|
|
363
477
|
})
|
|
364
|
-
)
|
|
365
|
-
|
|
478
|
+
);
|
|
366
479
|
} else if (!awaitingStepIds.length) {
|
|
367
|
-
_izContext.logger.debug(
|
|
480
|
+
_izContext.logger.debug('dynamoDb storageResourceTag');
|
|
368
481
|
let messageObject = {
|
|
369
482
|
firstObject: firstObject,
|
|
370
483
|
secondObject: secondObject,
|
|
@@ -374,20 +487,40 @@ export default async function updateRelationship(
|
|
|
374
487
|
parentFlowId
|
|
375
488
|
};
|
|
376
489
|
|
|
377
|
-
if (
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
490
|
+
if (
|
|
491
|
+
callingFlowConfig[
|
|
492
|
+
callingFlowSharedLib.consts.CALLINGFLOW_PROPERTYNAME
|
|
493
|
+
]
|
|
494
|
+
) {
|
|
495
|
+
_izContext.logger.debug('have callingFlow');
|
|
496
|
+
messageObject =
|
|
497
|
+
callingFlowSharedLib.addPassBackPropertiesToSnsResponseMessageObject(
|
|
498
|
+
callingFlowConfig,
|
|
499
|
+
messageObject
|
|
500
|
+
);
|
|
501
|
+
|
|
502
|
+
let messageAttributes =
|
|
503
|
+
callingFlowSharedLib.addCallingFlowToSnsResponseMessageAttributes(
|
|
504
|
+
callingFlowConfig,
|
|
505
|
+
{}
|
|
506
|
+
);
|
|
382
507
|
let sendMessageToOutCreateRelComplete = {
|
|
383
508
|
Message: JSON.stringify(messageObject),
|
|
384
|
-
MessageAttributes: sns.createStringMessageAttributes(
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
509
|
+
MessageAttributes: sns.createStringMessageAttributes(
|
|
510
|
+
_izContext,
|
|
511
|
+
messageAttributes
|
|
512
|
+
),
|
|
513
|
+
TopicArn: snsSharedLib.snsTopicArnByFlowSchema(
|
|
514
|
+
_izContext,
|
|
515
|
+
TOPIC_NAME_GENERATE_CODE.outCreateRelComplete
|
|
516
|
+
)
|
|
517
|
+
};
|
|
518
|
+
_izContext.logger.debug(
|
|
519
|
+
'send Message to outCreateRelationshipComplete :::',
|
|
520
|
+
sendMessageToOutCreateRelComplete
|
|
521
|
+
);
|
|
388
522
|
await sns.publishAsync(_izContext, sendMessageToOutCreateRelComplete);
|
|
389
523
|
}
|
|
390
|
-
|
|
391
524
|
}
|
|
392
525
|
|
|
393
526
|
return {
|
|
@@ -400,7 +533,7 @@ export default async function updateRelationship(
|
|
|
400
533
|
};
|
|
401
534
|
}
|
|
402
535
|
} catch (err) {
|
|
403
|
-
_izContext.logger.error('error updateRelationship: ', err)
|
|
404
|
-
throw
|
|
536
|
+
_izContext.logger.error('error updateRelationship: ', err);
|
|
537
|
+
throw err;
|
|
405
538
|
}
|
|
406
539
|
}
|