@izara_project/izara-core-generate-service-code 1.0.66 → 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/docs/TriggeredCache Flow.drawio +193 -0
- package/docs/TriggeredCacheFlow.mmd +47 -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 +108 -1
- package/src/emit/crud/emitCrudApplicationArtifacts.js +9 -5
- package/src/emit/crud/emitDynamicCrudFlowSchemas.js +1 -2
- package/src/emit/crud/templates/CreateEndpoint_Main.ejs +300 -109
- package/src/emit/crud/templates/DeleteEndpoint_Main.ejs +221 -143
- package/src/emit/crud/templates/FlowEndpointBeforeLogical_Main.ejs +22 -6
- package/src/emit/crud/templates/FlowEndpointComplete_Main.ejs +150 -38
- package/src/emit/crud/templates/FlowEndpoint_HdrWbs.ejs +51 -31
- package/src/emit/crud/templates/FlowHandler_HdrApi.ejs +57 -31
- 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 +6 -3
- package/src/emit/crud/templates/GetRangeEndpoint_Main.ejs +2 -2
- package/src/emit/crud/templates/UpdateEndpoint_Main.ejs +407 -252
- package/src/emit/custom/customFlows.js +112 -31
- package/src/emit/custom/emitCustomFlowApplicationArtifacts.js +89 -77
- package/src/emit/custom/templates/FlowEndpoint_Main.ejs +49 -37
- 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 +46 -12
- package/src/emit/rbac/emitDynamicRbacFlowSchemas.js +28 -15
- package/src/emit/rbac/emitRbacApplicationArtifacts.js +179 -66
- 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/emitRelationshipApplicationArtifacts.js +6 -5
- package/src/emit/relationship/templates/ChangeRelationshipComplete_Main.ejs +64 -37
- package/src/emit/relationship/templates/ChangeRelationship_Main.ejs +260 -144
- 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 +499 -108
- 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/emit/system/emitSystemWebSocketArtifacts.js +2 -1
- package/src/generate.js +8 -4
- package/test/createTargetRoleHandler.test.js +63 -14
- package/test/crudApplicationArtifacts.test.js +1 -1
- package/test/customFlowApplicationArtifacts.test.js +71 -43
- 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 +11 -13
- package/test/resourceArtifacts.test.js +13 -3
- package/src/emit/rbac/templates/UserRbacFlow_HdrInv.ejs +0 -10
|
@@ -15,39 +15,37 @@ 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 { objectHash as hash } from '@izara_project/izara-shared-core';
|
|
21
19
|
|
|
22
20
|
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
|
|
27
|
-
|
|
28
|
-
import {
|
|
29
|
-
|
|
30
|
-
|
|
21
|
+
import lambdaSharedLib from '@izara_project/izara-core-library-lambda';
|
|
22
|
+
import snsSharedLib from '@izara_project/izara-core-library-sns';
|
|
23
|
+
import asyncFlowSharedLib from '@izara_project/izara-core-library-asynchronous-flow';
|
|
24
|
+
import dynamodbSharedLib from '@izara_project/izara-core-library-dynamodb';
|
|
25
|
+
|
|
26
|
+
import {
|
|
27
|
+
sns,
|
|
28
|
+
lambda
|
|
29
|
+
} from '@izara_project/izara-core-library-external-request';
|
|
30
|
+
|
|
31
|
+
import {
|
|
32
|
+
getObjectSchema,
|
|
33
|
+
utils,
|
|
34
|
+
serviceConfig,
|
|
35
|
+
consts,
|
|
36
|
+
relSchemaLib,
|
|
37
|
+
identifiersObject
|
|
38
|
+
} from '@izara_project/izara-core-library-service-schemas';
|
|
31
39
|
const { findLinksByObjTypes } = relSchemaLib;
|
|
32
40
|
|
|
33
|
-
const {
|
|
34
|
-
|
|
35
|
-
getObjSchemaS3WithHierarchy
|
|
36
|
-
} = getObjectSchema
|
|
41
|
+
const { getRelationshipSchemaWithCache, getObjSchemaS3WithHierarchy } =
|
|
42
|
+
getObjectSchema;
|
|
37
43
|
|
|
38
|
-
const {
|
|
39
|
-
createLinkTypeId
|
|
40
|
-
} = utils;
|
|
44
|
+
const { createLinkTypeId } = utils;
|
|
41
45
|
|
|
42
|
-
const {
|
|
43
|
-
getGraphServiceTagWithCache
|
|
44
|
-
} = serviceConfig;
|
|
46
|
+
const { getGraphServiceTagWithCache } = serviceConfig;
|
|
45
47
|
|
|
46
|
-
const {
|
|
47
|
-
PREFIX,
|
|
48
|
-
TOPIC_NAME_GENERATE_CODE,
|
|
49
|
-
TOPIC_NAME_GRAPH_HANDLER
|
|
50
|
-
} = consts;
|
|
48
|
+
const { PREFIX, TOPIC_NAME_GENERATE_CODE, TOPIC_NAME_GRAPH_HANDLER } = consts;
|
|
51
49
|
|
|
52
50
|
import { consts as coreConsts } from '@izara_project/izara-core-library-core';
|
|
53
51
|
|
|
@@ -68,24 +66,27 @@ import { consts as coreConsts } from '@izara_project/izara-core-library-core';
|
|
|
68
66
|
export default async function getRelationship(
|
|
69
67
|
_izContext,
|
|
70
68
|
requestParams,
|
|
71
|
-
callingFlowConfig = {}
|
|
69
|
+
callingFlowConfig = {}
|
|
72
70
|
//(<additionalParams>)
|
|
73
71
|
//(</additionalParams>)
|
|
74
72
|
) {
|
|
75
|
-
|
|
76
|
-
|
|
77
73
|
try {
|
|
78
74
|
_izContext.logger.debug('createRelationship _izContext: ', _izContext);
|
|
79
|
-
_izContext.logger.debug(
|
|
80
|
-
|
|
81
|
-
|
|
75
|
+
_izContext.logger.debug(
|
|
76
|
+
'createRelationship requestParams: ',
|
|
77
|
+
requestParams
|
|
78
|
+
);
|
|
79
|
+
_izContext.logger.debug(
|
|
80
|
+
'createRelationship callingFlowConfig: ',
|
|
81
|
+
callingFlowConfig
|
|
82
|
+
);
|
|
82
83
|
|
|
83
84
|
const {
|
|
84
85
|
firstObject,
|
|
85
86
|
secondObject,
|
|
86
87
|
relType,
|
|
87
88
|
relId,
|
|
88
|
-
relationshipDirection
|
|
89
|
+
relationshipDirection
|
|
89
90
|
//(<requestParamGetRel>)
|
|
90
91
|
//(</requestParamGetRel>)
|
|
91
92
|
} = requestParams;
|
|
@@ -95,34 +96,56 @@ export default async function getRelationship(
|
|
|
95
96
|
//(<beforeValidateGetRel>)
|
|
96
97
|
//(</beforeValidateGetRel>).
|
|
97
98
|
// validate object and identifiers
|
|
98
|
-
async function validateIdentifiersExists(
|
|
99
|
-
|
|
99
|
+
async function validateIdentifiersExists(
|
|
100
|
+
_izContext,
|
|
101
|
+
objType,
|
|
102
|
+
identifiersObject
|
|
103
|
+
) {
|
|
100
104
|
const objTypeString = `objType:{ serviceTag:${objType.serviceTag}, objectType:${objType.objectType} }`;
|
|
101
|
-
const objectSchema = await getObjSchemaS3WithHierarchy(
|
|
105
|
+
const objectSchema = await getObjSchemaS3WithHierarchy(
|
|
106
|
+
_izContext,
|
|
107
|
+
objType
|
|
108
|
+
);
|
|
102
109
|
|
|
103
110
|
if (!objectSchema) {
|
|
104
|
-
errorsFound.push(
|
|
111
|
+
errorsFound.push(
|
|
112
|
+
`validateIdentifiers, not found schema of ${objTypeString}`
|
|
113
|
+
);
|
|
105
114
|
}
|
|
106
115
|
|
|
107
116
|
for (const schemaIdentifier of objectSchema.identifiers) {
|
|
108
|
-
let identifierNames = schemaIdentifier.fieldNames || [
|
|
117
|
+
let identifierNames = schemaIdentifier.fieldNames || [
|
|
118
|
+
schemaIdentifier.fieldName
|
|
119
|
+
];
|
|
109
120
|
for (const identifierName of identifierNames) {
|
|
110
121
|
if (!identifiersObject.hasOwnProperty(identifierName)) {
|
|
111
|
-
errorsFound.push(
|
|
122
|
+
errorsFound.push(
|
|
123
|
+
`validateIdentifiers, ${objTypeString} property:${identifierName} not exists`
|
|
124
|
+
);
|
|
112
125
|
} else {
|
|
113
126
|
if (
|
|
114
|
-
typeof
|
|
115
|
-
typeof
|
|
127
|
+
typeof identifiersObject[identifierName] !== 'string' &&
|
|
128
|
+
typeof identifiersObject[identifierName] !== 'number'
|
|
116
129
|
) {
|
|
117
|
-
errorsFound.push(
|
|
130
|
+
errorsFound.push(
|
|
131
|
+
`validateIdentifiers, ${objTypeString} property:${identifierName} should be string or number`
|
|
132
|
+
);
|
|
118
133
|
}
|
|
119
134
|
}
|
|
120
135
|
}
|
|
121
136
|
}
|
|
122
137
|
}
|
|
123
138
|
|
|
124
|
-
await validateIdentifiersExists(
|
|
125
|
-
|
|
139
|
+
await validateIdentifiersExists(
|
|
140
|
+
_izContext,
|
|
141
|
+
firstObject.objType,
|
|
142
|
+
firstObject.identifiers
|
|
143
|
+
);
|
|
144
|
+
await validateIdentifiersExists(
|
|
145
|
+
_izContext,
|
|
146
|
+
secondObject.objType,
|
|
147
|
+
secondObject.identifiers
|
|
148
|
+
);
|
|
126
149
|
// finished validate object and identifiers
|
|
127
150
|
|
|
128
151
|
//(<afterValidateGetRel>)
|
|
@@ -131,14 +154,23 @@ export default async function getRelationship(
|
|
|
131
154
|
//(<beforeGetRel>)
|
|
132
155
|
//(</beforeGetRel>)
|
|
133
156
|
|
|
134
|
-
const relationshipSchema = await getRelationshipSchemaWithCache(
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
_izContext.logger.debug(
|
|
157
|
+
const relationshipSchema = await getRelationshipSchemaWithCache(
|
|
158
|
+
_izContext,
|
|
159
|
+
relType
|
|
160
|
+
);
|
|
161
|
+
_izContext.logger.debug('relationshipSchema: ', relationshipSchema);
|
|
162
|
+
|
|
163
|
+
const links = await findLinksByObjTypes(
|
|
164
|
+
_izContext,
|
|
165
|
+
[firstObject.objType, secondObject.objType],
|
|
166
|
+
relationshipSchema.links
|
|
167
|
+
);
|
|
168
|
+
_izContext.logger.debug('links', links);
|
|
139
169
|
if (!links.length) {
|
|
140
|
-
errorsFound.push(
|
|
141
|
-
|
|
170
|
+
errorsFound.push(
|
|
171
|
+
`not found link between ${JSON.stringify({ firstObject: firstObject.objType })} ${JSON.stringify({ secondObject: secondObject.objType })}`
|
|
172
|
+
);
|
|
173
|
+
}
|
|
142
174
|
|
|
143
175
|
let targetStorageResources = [];
|
|
144
176
|
|
|
@@ -147,59 +179,88 @@ export default async function getRelationship(
|
|
|
147
179
|
let secondObjectHie;
|
|
148
180
|
|
|
149
181
|
if (firstObject && Object.values(firstObject).length > 0) {
|
|
150
|
-
firstObjectHie = await getObjectSchema.getObjSchemaS3WithHierarchy(
|
|
151
|
-
|
|
182
|
+
firstObjectHie = await getObjectSchema.getObjSchemaS3WithHierarchy(
|
|
183
|
+
_izContext,
|
|
184
|
+
firstObject.objType
|
|
185
|
+
);
|
|
186
|
+
}
|
|
152
187
|
|
|
153
188
|
if (secondObject && Object.values(secondObject).length > 0) {
|
|
154
|
-
secondObjectHie = await getObjectSchema.getObjSchemaS3WithHierarchy(
|
|
155
|
-
|
|
189
|
+
secondObjectHie = await getObjectSchema.getObjSchemaS3WithHierarchy(
|
|
190
|
+
_izContext,
|
|
191
|
+
secondObject.objType
|
|
192
|
+
);
|
|
193
|
+
}
|
|
156
194
|
|
|
157
195
|
if (firstObjectHie || firstObject || secondObjectHie || secondObject) {
|
|
158
196
|
// find targetStorageResources and validate each storageResources
|
|
159
197
|
await Promise.all(
|
|
160
|
-
relationshipSchema.links.map(
|
|
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
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
198
|
+
relationshipSchema.links.map(
|
|
199
|
+
async ({ from, to, storageResourceTags }) => {
|
|
200
|
+
const { serviceTag: fromServiceTag, objectType: fromObjectType } =
|
|
201
|
+
from.objType;
|
|
202
|
+
const { serviceTag: toServiceTag, objectType: toObjectType } =
|
|
203
|
+
to.objType;
|
|
204
|
+
|
|
205
|
+
const {
|
|
206
|
+
serviceTag: firstServiceTag,
|
|
207
|
+
objectType: firstObjectType
|
|
208
|
+
} = firstObjectHie.extendObjType || firstObject.objType;
|
|
209
|
+
const {
|
|
210
|
+
serviceTag: secondServiceTag,
|
|
211
|
+
objectType: secondObjectType
|
|
212
|
+
} = secondObjectHie.extendObjType || secondObject.objType;
|
|
213
|
+
|
|
214
|
+
// find exists link
|
|
215
|
+
if (
|
|
216
|
+
(firstServiceTag === fromServiceTag &&
|
|
217
|
+
firstObjectType === fromObjectType &&
|
|
218
|
+
secondServiceTag === toServiceTag &&
|
|
219
|
+
secondObjectType === toObjectType) ||
|
|
220
|
+
(firstServiceTag === toServiceTag &&
|
|
221
|
+
firstObjectType === toObjectType &&
|
|
222
|
+
secondServiceTag === fromServiceTag &&
|
|
223
|
+
secondObjectType === fromObjectType)
|
|
224
|
+
) {
|
|
225
|
+
// check founded storageResource of link and collect used storageResources
|
|
226
|
+
await Promise.all(
|
|
227
|
+
storageResourceTags.map(async (storageResourceTag) => {
|
|
228
|
+
const usedStorageResource =
|
|
229
|
+
relationshipSchema.storageResources[storageResourceTag];
|
|
230
|
+
|
|
231
|
+
if (
|
|
232
|
+
usedStorageResource.storageType ===
|
|
233
|
+
consts.STORAGE_TYPES.graph
|
|
234
|
+
) {
|
|
235
|
+
const graphServiceTag = await getGraphServiceTagWithCache(
|
|
236
|
+
_izContext,
|
|
237
|
+
usedStorageResource.graphServerTag
|
|
238
|
+
);
|
|
239
|
+
if (!graphServiceTag) {
|
|
240
|
+
errorsFound.push(
|
|
241
|
+
`storageResourceTag: ${storageResourceTag} invalid, not found graph serviceTag from graphServerTag: ${usedStorageResource.graphServerTag}`
|
|
242
|
+
);
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
targetStorageResources.push({
|
|
246
|
+
...usedStorageResource,
|
|
247
|
+
graphServiceTag: graphServiceTag
|
|
248
|
+
});
|
|
249
|
+
} else {
|
|
250
|
+
targetStorageResources.push(usedStorageResource);
|
|
251
|
+
}
|
|
252
|
+
})
|
|
253
|
+
);
|
|
254
|
+
}
|
|
197
255
|
}
|
|
198
|
-
|
|
256
|
+
)
|
|
199
257
|
);
|
|
200
258
|
//(<afterGetRelCreateRel>)
|
|
201
259
|
//(</afterGetRelCreateRel>)
|
|
202
|
-
_izContext.logger.debug(
|
|
260
|
+
_izContext.logger.debug(
|
|
261
|
+
'targetStorageResources: ',
|
|
262
|
+
targetStorageResources
|
|
263
|
+
);
|
|
203
264
|
|
|
204
265
|
if (!targetStorageResources.length) {
|
|
205
266
|
errorsFound.push(`Not found link from relationship schema`);
|
|
@@ -209,10 +270,8 @@ export default async function getRelationship(
|
|
|
209
270
|
errorsFound.push(`relationshipSchema not exists`);
|
|
210
271
|
}
|
|
211
272
|
|
|
212
|
-
|
|
213
273
|
// if found errors will stop processing
|
|
214
274
|
if (errorsFound.length) {
|
|
215
|
-
|
|
216
275
|
let getRelCompleteMsg = {
|
|
217
276
|
firstObject: firstObject,
|
|
218
277
|
secondObject: secondObject,
|
|
@@ -225,19 +284,38 @@ export default async function getRelationship(
|
|
|
225
284
|
};
|
|
226
285
|
|
|
227
286
|
// if have callingFlow will send to message complete
|
|
228
|
-
if (
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
287
|
+
if (
|
|
288
|
+
callingFlowConfig[callingFlowSharedLib.consts.CALLINGFLOW_PROPERTYNAME]
|
|
289
|
+
) {
|
|
290
|
+
_izContext.logger.debug('HAVE CallingFlow');
|
|
291
|
+
|
|
292
|
+
getRelCompleteMsg =
|
|
293
|
+
callingFlowSharedLib.addPassBackPropertiesToSnsResponseMessageObject(
|
|
294
|
+
callingFlowConfig,
|
|
295
|
+
getRelCompleteMsg
|
|
296
|
+
);
|
|
297
|
+
let messageAttributes =
|
|
298
|
+
callingFlowSharedLib.addCallingFlowToSnsResponseMessageAttributes(
|
|
299
|
+
callingFlowConfig,
|
|
300
|
+
{}
|
|
301
|
+
);
|
|
233
302
|
|
|
234
303
|
let messageParams = {
|
|
235
304
|
Message: JSON.stringify(getRelCompleteMsg),
|
|
236
|
-
MessageAttributes: sns.createStringMessageAttributes(
|
|
237
|
-
|
|
305
|
+
MessageAttributes: sns.createStringMessageAttributes(
|
|
306
|
+
_izContext,
|
|
307
|
+
messageAttributes
|
|
308
|
+
),
|
|
309
|
+
TopicArn: snsSharedLib.snsTopicArnByFlowSchema(
|
|
310
|
+
_izContext,
|
|
311
|
+
TOPIC_NAME_GENERATE_CODE.outGetRelComplete
|
|
312
|
+
)
|
|
238
313
|
};
|
|
239
314
|
|
|
240
|
-
_izContext.logger.debug(
|
|
315
|
+
_izContext.logger.debug(
|
|
316
|
+
'messageParams OutCreateRelationshipComplete ::::::: ',
|
|
317
|
+
messageParams
|
|
318
|
+
);
|
|
241
319
|
await sns.publishAsync(_izContext, messageParams);
|
|
242
320
|
}
|
|
243
321
|
|
|
@@ -248,7 +326,8 @@ export default async function getRelationship(
|
|
|
248
326
|
let targetGraphStorageResources = []; // collect used graph storageResources, filtered duplicate graphServiceTag from graphServerTag out
|
|
249
327
|
|
|
250
328
|
for (const targetStorageResource of targetStorageResources) {
|
|
251
|
-
if (
|
|
329
|
+
if (
|
|
330
|
+
targetStorageResource.storageType === consts.STORAGE_TYPES.graph &&
|
|
252
331
|
!usedGraphServiceTag.includes(targetStorageResource.graphServiceTag)
|
|
253
332
|
) {
|
|
254
333
|
usedGraphServiceTag.push(targetStorageResource.graphServiceTag);
|
|
@@ -267,28 +346,40 @@ export default async function getRelationship(
|
|
|
267
346
|
relType,
|
|
268
347
|
relId,
|
|
269
348
|
relationshipDirection
|
|
270
|
-
)
|
|
271
|
-
} else if (
|
|
272
|
-
|
|
349
|
+
);
|
|
350
|
+
} else if (
|
|
351
|
+
storageResource.storageType === consts.STORAGE_TYPES.dynamoDB
|
|
352
|
+
) {
|
|
273
353
|
// if have storageResource.storageType === "dynamoDB" will create relationship here
|
|
274
354
|
let tableNameFrom = `${firstObject.objType.serviceTag}_${firstObject.objType.objectType}__${relType.relationshipTag}__${secondObject.objType.serviceTag}_${secondObject.objType.objectType}`;
|
|
275
355
|
|
|
276
|
-
let identifiersConcatFirstObject =
|
|
277
|
-
|
|
356
|
+
let identifiersConcatFirstObject =
|
|
357
|
+
await identifiersObject.identifiersConcatFromIdentifiers(
|
|
358
|
+
_izContext,
|
|
359
|
+
firstObject.objType,
|
|
360
|
+
firstObject.identifiers
|
|
361
|
+
);
|
|
362
|
+
let identifiersConcatSecondObject =
|
|
363
|
+
await identifiersObject.identifiersConcatFromIdentifiers(
|
|
364
|
+
_izContext,
|
|
365
|
+
secondObject.objType,
|
|
366
|
+
secondObject.identifiers
|
|
367
|
+
);
|
|
278
368
|
const firstObjectIdentifiersConcat = `${firstObject.objType.serviceTag}_${firstObject.objType.objectType}__identifiersConcat`;
|
|
279
369
|
const secondObjectIdentifiersConcat = `${secondObject.objType.serviceTag}_${secondObject.objType.objectType}__identifiersConcat`;
|
|
280
370
|
// putItem first Object DynamoDb
|
|
281
|
-
let getResultFromDynamo = await dynamodbSharedLib.getItem(
|
|
371
|
+
let getResultFromDynamo = await dynamodbSharedLib.getItem(
|
|
372
|
+
_izContext,
|
|
282
373
|
await dynamodbSharedLib.tableName(_izContext, tableNameFrom),
|
|
283
374
|
{
|
|
284
375
|
[firstObjectIdentifiersConcat]: identifiersConcatFirstObject,
|
|
285
376
|
[secondObjectIdentifiersConcat]: identifiersConcatSecondObject
|
|
286
377
|
}
|
|
287
|
-
)
|
|
378
|
+
);
|
|
288
379
|
result = getResultFromDynamo;
|
|
289
380
|
}
|
|
290
381
|
})
|
|
291
|
-
)
|
|
382
|
+
);
|
|
292
383
|
|
|
293
384
|
let messageObject = {
|
|
294
385
|
firstObject: firstObject,
|
|
@@ -299,19 +390,37 @@ export default async function getRelationship(
|
|
|
299
390
|
result: result
|
|
300
391
|
};
|
|
301
392
|
|
|
302
|
-
if (
|
|
303
|
-
|
|
304
|
-
|
|
393
|
+
if (
|
|
394
|
+
callingFlowConfig[callingFlowSharedLib.consts.CALLINGFLOW_PROPERTYNAME]
|
|
395
|
+
) {
|
|
396
|
+
_izContext.logger.debug('have callingFlow');
|
|
397
|
+
messageObject =
|
|
398
|
+
callingFlowSharedLib.addPassBackPropertiesToSnsResponseMessageObject(
|
|
399
|
+
callingFlowConfig,
|
|
400
|
+
messageObject
|
|
401
|
+
);
|
|
305
402
|
|
|
306
|
-
let messageAttributes =
|
|
403
|
+
let messageAttributes =
|
|
404
|
+
callingFlowSharedLib.addCallingFlowToSnsResponseMessageAttributes(
|
|
405
|
+
callingFlowConfig,
|
|
406
|
+
{}
|
|
407
|
+
);
|
|
307
408
|
let sendMessageToOutGetRelComplete = {
|
|
308
409
|
Message: JSON.stringify(messageObject),
|
|
309
|
-
MessageAttributes: sns.createStringMessageAttributes(
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
410
|
+
MessageAttributes: sns.createStringMessageAttributes(
|
|
411
|
+
_izContext,
|
|
412
|
+
messageAttributes
|
|
413
|
+
),
|
|
414
|
+
TopicArn: snsSharedLib.snsTopicArnByFlowSchema(
|
|
415
|
+
_izContext,
|
|
416
|
+
TOPIC_NAME_GENERATE_CODE.outGetRelComplete
|
|
417
|
+
)
|
|
418
|
+
};
|
|
419
|
+
_izContext.logger.debug(
|
|
420
|
+
'send Message to outCreateRelationshipComplete :::',
|
|
421
|
+
sendMessageToOutGetRelComplete
|
|
422
|
+
);
|
|
313
423
|
await sns.publishAsync(_izContext, sendMessageToOutGetRelComplete);
|
|
314
|
-
|
|
315
424
|
}
|
|
316
425
|
|
|
317
426
|
return {
|
|
@@ -321,12 +430,10 @@ export default async function getRelationship(
|
|
|
321
430
|
relId: relId,
|
|
322
431
|
relationshipDirection,
|
|
323
432
|
result: result,
|
|
324
|
-
status:
|
|
433
|
+
status: 'complete'
|
|
325
434
|
};
|
|
326
|
-
|
|
327
|
-
|
|
328
435
|
} catch (err) {
|
|
329
|
-
_izContext.logger.error('error getRelationship: ', err)
|
|
330
|
-
throw
|
|
436
|
+
_izContext.logger.error('error getRelationship: ', err);
|
|
437
|
+
throw err;
|
|
331
438
|
}
|
|
332
439
|
}
|