@izara_project/izara-core-generate-service-code 1.0.67 → 1.0.69
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 +104 -0
- package/src/compile/compileProject.js +40 -9
- package/src/compile/loadSchemas.js +120 -11
- package/src/emit/crud/emitCrudApplicationArtifacts.js +188 -41
- package/src/emit/crud/emitDynamicCrudFlowSchemas.js +34 -18
- package/src/emit/crud/generateCrudApplicationArtifacts.js +14 -6
- package/src/emit/crud/generateDynamicCrudFlowSchemas.js +4 -1
- 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 +6 -3
- 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 +68 -28
- package/src/emit/custom/emitCustomFlowApplicationArtifacts.js +520 -123
- package/src/emit/custom/generateCustomFlowApplicationArtifacts.js +28 -8
- 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 +14 -9
- package/src/emit/custom/templates/s3/ProcessS3File_Main.ejs +11 -8
- package/src/emit/custom/templates/s3/ReservedLimit_HdrSqs.ejs +65 -56
- 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 +272 -79
- package/src/emit/function/templates/ApiFunction_Yaml.ejs +7 -0
- package/src/emit/function/templates/EventBridgeFunction_Yaml.ejs +6 -0
- package/src/emit/function/templates/InvFunction_Yaml.ejs +5 -0
- package/src/emit/function/templates/S3Function_Yaml.ejs +16 -0
- package/src/emit/function/templates/SqsFunction_Yaml.ejs +10 -0
- package/src/emit/function/templates/WbsFunction_Yaml.ejs +10 -0
- package/src/emit/rbac/emitDynamicRbacFlowSchemas.js +40 -29
- package/src/emit/rbac/emitRbacApplicationArtifacts.js +171 -72
- package/src/emit/rbac/generateCreateTargetRoleHandler.js +6 -4
- package/src/emit/rbac/generateDynamicRbacFlowSchemas.js +8 -2
- package/src/emit/rbac/rbacFlowTag.js +3 -1
- 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 +26 -11
- package/src/emit/relationship/emitRelationshipApplicationArtifacts.js +179 -37
- package/src/emit/relationship/generateDynamicRelationshipFlowSchemas.js +8 -2
- package/src/emit/relationship/generateRelationshipApplicationArtifacts.js +15 -6
- 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 +274 -105
- package/src/emit/resource/generateResourceArtifacts.js +15 -6
- package/src/emit/resource/templates/GeneratedLambdaRoleServiceConfig.ejs +139 -0
- package/src/emit/resource/templates/S3Bucket_Yaml.ejs +19 -0
- package/src/emit/resource/templates/S3Subscription_Yaml.ejs +7 -0
- package/src/emit/resource/templates/WebSocketSubscription_Yaml.ejs +7 -0
- package/src/emit/system/emitSystemWebSocketArtifacts.js +61 -165
- package/src/emit/system/templates/WebSocketComplete_HdrSqs.ejs +32 -0
- package/src/emit/system/templates/WebSocketComplete_Main.ejs +46 -0
- package/src/emit/system/templates/WebSocketComplete_Yaml.ejs +19 -0
- package/src/emit/system/templates/WebSocketConnect.ejs +25 -0
- package/src/emit/system/templates/WebSocketConnect_Yaml.ejs +11 -0
- package/src/generate.js +141 -34
- package/src/generateIntTest.js +76 -28
- package/src/generateResourceIntTest.js +35 -12
- package/src/generateResources/IntTest/generateResources/generateResources.js +5 -2
- package/src/generateResources/IntTest/generateResources/templateResources.ejs +18 -30
- package/src/generateResources/IntTest/generateTests/events/events.js +1 -1
- package/src/generateResources/IntTest/generateTests/events/templateEvents.ejs +13 -10
- package/src/generateResources/IntTest/generateTests/generateTemplate.js +2 -2
- package/src/generateResources/IntTest/generateTests/pathIntTest/pathIntTest.js +2 -1
- package/src/generateResources/IntTest/generateTests/pathIntTest/template.ejs +1 -3
- package/src/generateResources/IntTest/generateTests/tests/templateTests.ejs +1 -1
- package/src/generateResources/IntTest/generateTests/tests/tests.js +7 -3
- package/src/generateResources/IntTest/libs/{libs.js → IntTestGenerateLib.js} +34 -23
- package/src/generateResources/IntTest/upload/uploadIntTest.js +33 -19
- package/src/intTestGeneratorShared.js +15 -10
- package/src/output/commitArtifacts.js +99 -39
- package/src/output/mergeHooks.js +24 -10
- package/src/output/validateArtifacts.js +37 -27
- package/src/plan/buildGenerationPlan.js +24 -13
- package/test/core.test.js +116 -49
- package/test/createTargetRoleHandler.test.js +63 -14
- package/test/crudApplicationArtifacts.test.js +128 -23
- package/test/customFlowApplicationArtifacts.test.js +391 -84
- package/test/dynamicCrudFlowSchemas.test.js +74 -26
- package/test/dynamicRbacFlowSchemas.test.js +63 -20
- package/test/dynamicRelationshipFlowSchemas.test.js +65 -18
- package/test/functionYamlArtifact.test.js +67 -10
- package/test/intTestApi.test.js +9 -10
- package/test/publicApi.test.js +184 -44
- package/test/relationshipApplicationArtifacts.test.js +90 -19
- package/test/resourceArtifacts.test.js +183 -33
- package/docs/test.png +0 -0
- package/src/emit/rbac/templates/UserRbacFlow_HdrInv.ejs +0 -10
- package/src/emit/relationship/dynamicRelationshipFlowSchemaTemplate.js +0 -11
- /package/docs/{test.mmd → TriggeredCacheFlow.mmd} +0 -0
|
@@ -15,36 +15,34 @@ 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 {
|
|
19
|
+
objectHash as hash,
|
|
20
|
+
identifierUuid
|
|
21
|
+
} from '@izara_project/izara-shared-core';
|
|
20
22
|
|
|
21
23
|
import callingFlowSharedLib from '@izara_project/izara-core-library-calling-flow';
|
|
22
|
-
import lambdaSharedLib from
|
|
23
|
-
import snsSharedLib from
|
|
24
|
-
import asyncFlowSharedLib from
|
|
25
|
-
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';
|
|
26
28
|
|
|
27
|
-
import { sns } from
|
|
28
|
-
import {
|
|
29
|
+
import { sns } from '@izara_project/izara-core-library-external-request';
|
|
30
|
+
import {
|
|
31
|
+
getObjectSchema,
|
|
32
|
+
utils,
|
|
33
|
+
serviceConfig,
|
|
34
|
+
consts,
|
|
35
|
+
identifiersObject
|
|
36
|
+
} from '@izara_project/izara-core-library-service-schemas';
|
|
29
37
|
|
|
30
|
-
const {
|
|
31
|
-
|
|
32
|
-
getObjSchemaS3WithHierarchy
|
|
33
|
-
} = getObjectSchema
|
|
38
|
+
const { getRelationshipSchemaWithCache, getObjSchemaS3WithHierarchy } =
|
|
39
|
+
getObjectSchema;
|
|
34
40
|
|
|
35
|
-
const {
|
|
36
|
-
createLinkTypeId
|
|
37
|
-
} = utils;
|
|
41
|
+
const { createLinkTypeId } = utils;
|
|
38
42
|
|
|
39
|
-
const {
|
|
40
|
-
getGraphServiceTagWithCache
|
|
41
|
-
} = serviceConfig;
|
|
43
|
+
const { getGraphServiceTagWithCache } = serviceConfig;
|
|
42
44
|
|
|
43
|
-
const {
|
|
44
|
-
PREFIX,
|
|
45
|
-
TOPIC_NAME_GENERATE_CODE,
|
|
46
|
-
TOPIC_NAME_GRAPH_HANDLER
|
|
47
|
-
} = consts;
|
|
45
|
+
const { PREFIX, TOPIC_NAME_GENERATE_CODE, TOPIC_NAME_GRAPH_HANDLER } = consts;
|
|
48
46
|
|
|
49
47
|
//(<optionalRequire>)
|
|
50
48
|
//(</optionalRequire>)
|
|
@@ -63,17 +61,20 @@ const {
|
|
|
63
61
|
export default async function deleteRelationship(
|
|
64
62
|
_izContext,
|
|
65
63
|
requestParams,
|
|
66
|
-
callingFlowConfig = {}
|
|
64
|
+
callingFlowConfig = {}
|
|
67
65
|
//(<additionalParams>)
|
|
68
66
|
//(</additionalParams>)
|
|
69
67
|
) {
|
|
70
|
-
|
|
71
|
-
|
|
72
68
|
try {
|
|
73
69
|
_izContext.logger.debug('deleteRelationship _izContext: ', _izContext);
|
|
74
|
-
_izContext.logger.debug(
|
|
75
|
-
|
|
76
|
-
|
|
70
|
+
_izContext.logger.debug(
|
|
71
|
+
'deleteRelationship requestParams: ',
|
|
72
|
+
requestParams
|
|
73
|
+
);
|
|
74
|
+
_izContext.logger.debug(
|
|
75
|
+
'deleteRelationship callingFlowConfig: ',
|
|
76
|
+
callingFlowConfig
|
|
77
|
+
);
|
|
77
78
|
|
|
78
79
|
const {
|
|
79
80
|
firstObject,
|
|
@@ -91,35 +92,57 @@ export default async function deleteRelationship(
|
|
|
91
92
|
//(<beforeValidateDeleteRel>)
|
|
92
93
|
//(</beforeValidateDeleteRel>)
|
|
93
94
|
// validate object and identifiers
|
|
94
|
-
async function validateIdentifiersExists(
|
|
95
|
-
|
|
95
|
+
async function validateIdentifiersExists(
|
|
96
|
+
_izContext,
|
|
97
|
+
objType,
|
|
98
|
+
identifiersObject
|
|
99
|
+
) {
|
|
96
100
|
const objTypeString = `objType:{ serviceTag:${objType.serviceTag}, objectType:${objType.objectType} }`;
|
|
97
|
-
const objectSchema = await getObjSchemaS3WithHierarchy(
|
|
101
|
+
const objectSchema = await getObjSchemaS3WithHierarchy(
|
|
102
|
+
_izContext,
|
|
103
|
+
objType
|
|
104
|
+
);
|
|
98
105
|
|
|
99
106
|
if (!objectSchema) {
|
|
100
|
-
errorsFound.push(
|
|
107
|
+
errorsFound.push(
|
|
108
|
+
`validateIdentifiers, not found schema of ${objTypeString}`
|
|
109
|
+
);
|
|
101
110
|
}
|
|
102
111
|
|
|
103
112
|
for (const schemaIdentifier of objectSchema.identifiers) {
|
|
104
|
-
let identifierNames = schemaIdentifier.fieldNames || [
|
|
113
|
+
let identifierNames = schemaIdentifier.fieldNames || [
|
|
114
|
+
schemaIdentifier.fieldName
|
|
115
|
+
];
|
|
105
116
|
for (const identifierName of identifierNames) {
|
|
106
117
|
if (!identifiersObject.hasOwnProperty(identifierName)) {
|
|
107
|
-
errorsFound.push(
|
|
118
|
+
errorsFound.push(
|
|
119
|
+
`validateIdentifiers, ${objTypeString} property:${identifierName} not exists`
|
|
120
|
+
);
|
|
108
121
|
} else {
|
|
109
122
|
if (
|
|
110
|
-
typeof
|
|
111
|
-
typeof
|
|
123
|
+
typeof identifiersObject[identifierName] !== 'string' &&
|
|
124
|
+
typeof identifiersObject[identifierName] !== 'number'
|
|
112
125
|
) {
|
|
113
|
-
errorsFound.push(
|
|
126
|
+
errorsFound.push(
|
|
127
|
+
`validateIdentifiers, ${objTypeString} property:${identifierName} should be string or number`
|
|
128
|
+
);
|
|
114
129
|
}
|
|
115
130
|
}
|
|
116
131
|
}
|
|
117
132
|
}
|
|
118
133
|
}
|
|
119
134
|
|
|
120
|
-
await validateIdentifiersExists(
|
|
135
|
+
await validateIdentifiersExists(
|
|
136
|
+
_izContext,
|
|
137
|
+
firstObject.objType,
|
|
138
|
+
firstObject.identifiers
|
|
139
|
+
);
|
|
121
140
|
if (Object.values(secondObject).length > 0) {
|
|
122
|
-
await validateIdentifiersExists(
|
|
141
|
+
await validateIdentifiersExists(
|
|
142
|
+
_izContext,
|
|
143
|
+
secondObject.objType,
|
|
144
|
+
secondObject.identifiers
|
|
145
|
+
);
|
|
123
146
|
}
|
|
124
147
|
// finished validate object and identifiers
|
|
125
148
|
|
|
@@ -129,8 +152,11 @@ export default async function deleteRelationship(
|
|
|
129
152
|
//(<beforeDeleteRel>)
|
|
130
153
|
//(</beforeDeleteRel>)
|
|
131
154
|
|
|
132
|
-
const relationshipSchema = await getRelationshipSchemaWithCache(
|
|
133
|
-
|
|
155
|
+
const relationshipSchema = await getRelationshipSchemaWithCache(
|
|
156
|
+
_izContext,
|
|
157
|
+
relType
|
|
158
|
+
);
|
|
159
|
+
_izContext.logger.debug('relationshipSchema: ', relationshipSchema);
|
|
134
160
|
|
|
135
161
|
let targetStorageResources = [];
|
|
136
162
|
|
|
@@ -139,28 +165,41 @@ export default async function deleteRelationship(
|
|
|
139
165
|
await Promise.all(
|
|
140
166
|
relationshipSchema.links.map(async ({ storageResourceTags }) => {
|
|
141
167
|
// check founded storageResource of link and collect used storageResources
|
|
142
|
-
await Promise.all(
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
if (
|
|
148
|
-
|
|
168
|
+
await Promise.all(
|
|
169
|
+
storageResourceTags.map(async (storageResourceTag) => {
|
|
170
|
+
const usedStorageResource =
|
|
171
|
+
relationshipSchema.storageResources[storageResourceTag];
|
|
172
|
+
|
|
173
|
+
if (
|
|
174
|
+
usedStorageResource.storageType === consts.STORAGE_TYPES.graph
|
|
175
|
+
) {
|
|
176
|
+
const graphServiceTag = await getGraphServiceTagWithCache(
|
|
177
|
+
_izContext,
|
|
178
|
+
usedStorageResource.graphServerTag
|
|
179
|
+
);
|
|
180
|
+
if (!graphServiceTag) {
|
|
181
|
+
errorsFound.push(
|
|
182
|
+
`storageResourceTag:${storageResourceTag} invalid, not found graph serviceTag from graphServerTag:${usedStorageResource.graphServerTag}`
|
|
183
|
+
);
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
targetStorageResources.push({
|
|
187
|
+
...usedStorageResource,
|
|
188
|
+
graphServiceTag: graphServiceTag
|
|
189
|
+
});
|
|
190
|
+
} else {
|
|
191
|
+
targetStorageResources.push(usedStorageResource);
|
|
149
192
|
}
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
...usedStorageResource,
|
|
153
|
-
graphServiceTag: graphServiceTag
|
|
154
|
-
});
|
|
155
|
-
} else {
|
|
156
|
-
targetStorageResources.push(usedStorageResource);
|
|
157
|
-
}
|
|
158
|
-
}));
|
|
193
|
+
})
|
|
194
|
+
);
|
|
159
195
|
})
|
|
160
196
|
);
|
|
161
197
|
//(<afterDeleteRel>)
|
|
162
198
|
//(</afterDeleteRel>)
|
|
163
|
-
_izContext.logger.debug(
|
|
199
|
+
_izContext.logger.debug(
|
|
200
|
+
'targetStorageResources: ',
|
|
201
|
+
targetStorageResources
|
|
202
|
+
);
|
|
164
203
|
|
|
165
204
|
if (!targetStorageResources.length) {
|
|
166
205
|
errorsFound.push(`Not found link from relationship schema`);
|
|
@@ -169,10 +208,8 @@ export default async function deleteRelationship(
|
|
|
169
208
|
errorsFound.push(`relationshipSchema not exists`);
|
|
170
209
|
}
|
|
171
210
|
|
|
172
|
-
|
|
173
211
|
// if found errors will stop processing
|
|
174
212
|
if (errorsFound.length) {
|
|
175
|
-
|
|
176
213
|
let deleteRelCompleteMsg = {
|
|
177
214
|
firstObject: firstObject,
|
|
178
215
|
secondObject: secondObject,
|
|
@@ -187,41 +224,69 @@ export default async function deleteRelationship(
|
|
|
187
224
|
};
|
|
188
225
|
|
|
189
226
|
// if have callingFlow will send to message complete
|
|
190
|
-
if (
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
227
|
+
if (
|
|
228
|
+
callingFlowConfig[callingFlowSharedLib.consts.CALLINGFLOW_PROPERTYNAME]
|
|
229
|
+
) {
|
|
230
|
+
_izContext.logger.debug('HAVE CallingFlow');
|
|
231
|
+
|
|
232
|
+
deleteRelCompleteMsg =
|
|
233
|
+
callingFlowSharedLib.addPassBackPropertiesToSnsResponseMessageObject(
|
|
234
|
+
callingFlowConfig,
|
|
235
|
+
deleteRelCompleteMsg
|
|
236
|
+
);
|
|
237
|
+
let messageAttributes =
|
|
238
|
+
callingFlowSharedLib.addCallingFlowToSnsResponseMessageAttributes(
|
|
239
|
+
callingFlowConfig,
|
|
240
|
+
{}
|
|
241
|
+
);
|
|
195
242
|
|
|
196
243
|
let messageParams = {
|
|
197
244
|
Message: JSON.stringify(deleteRelCompleteMsg),
|
|
198
|
-
MessageAttributes: sns.createStringMessageAttributes(
|
|
199
|
-
|
|
245
|
+
MessageAttributes: sns.createStringMessageAttributes(
|
|
246
|
+
_izContext,
|
|
247
|
+
messageAttributes
|
|
248
|
+
),
|
|
249
|
+
TopicArn: snsSharedLib.snsTopicArnByFlowSchema(
|
|
250
|
+
_izContext,
|
|
251
|
+
TOPIC_NAME_GENERATE_CODE.outDeleteRelComplete
|
|
252
|
+
)
|
|
200
253
|
};
|
|
201
254
|
|
|
202
|
-
_izContext.logger.debug(
|
|
255
|
+
_izContext.logger.debug(
|
|
256
|
+
'messageParams OutCreateRelationshipComplete ::::::: ',
|
|
257
|
+
messageParams
|
|
258
|
+
);
|
|
203
259
|
await sns.publishAsync(_izContext, messageParams);
|
|
204
260
|
}
|
|
205
261
|
|
|
206
262
|
return deleteRelCompleteMsg;
|
|
207
263
|
}
|
|
208
264
|
|
|
209
|
-
|
|
210
265
|
// before create awaitingStepId per graph storageResource
|
|
211
266
|
let linkTypeId;
|
|
212
|
-
if (
|
|
213
|
-
|
|
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
|
+
);
|
|
214
279
|
} else {
|
|
215
|
-
linkTypeId = hash({ objType: firstObject.objType, relType: relType })
|
|
280
|
+
linkTypeId = hash({ objType: firstObject.objType, relType: relType });
|
|
216
281
|
}
|
|
217
282
|
|
|
218
|
-
|
|
219
283
|
let usedGraphServiceTag = []; // collect used graph serviceTag, use to check duplicate graph serviceTag across graph serverTag
|
|
220
284
|
let targetGraphStorageResources = []; // collect used graph storageResources, filtered duplicate graphServiceTag from graphServerTag out
|
|
221
285
|
let awaitingStepIds = [];
|
|
222
286
|
|
|
223
287
|
for (const targetStorageResource of targetStorageResources) {
|
|
224
|
-
if (
|
|
288
|
+
if (
|
|
289
|
+
targetStorageResource.storageType === consts.STORAGE_TYPES.graph &&
|
|
225
290
|
!usedGraphServiceTag.includes(targetStorageResource.graphServiceTag)
|
|
226
291
|
) {
|
|
227
292
|
usedGraphServiceTag.push(targetStorageResource.graphServiceTag);
|
|
@@ -234,31 +299,45 @@ export default async function deleteRelationship(
|
|
|
234
299
|
PREFIX.deleteRel // prefix, use constant further
|
|
235
300
|
)
|
|
236
301
|
);
|
|
237
|
-
} else if (
|
|
302
|
+
} else if (
|
|
303
|
+
targetStorageResource.storageType === consts.STORAGE_TYPES.dynamoDB
|
|
304
|
+
) {
|
|
238
305
|
let tableNameFrom = `${firstObject.objType.serviceTag}_${firstObject.objType.objectType}__${relType.relationshipTag}__${secondObject.objType.serviceTag}_${secondObject.objType.objectType}`;
|
|
239
306
|
let tableNameTo = `${secondObject.objType.serviceTag}_${secondObject.objType.objectType}__${relType.relationshipTag}__${firstObject.objType.serviceTag}_${firstObject.objType.objectType}`;
|
|
240
307
|
|
|
241
|
-
let identifiersConcatFirstObject =
|
|
242
|
-
|
|
308
|
+
let identifiersConcatFirstObject =
|
|
309
|
+
await identifiersObject.identifiersConcatFromIdentifiers(
|
|
310
|
+
_izContext,
|
|
311
|
+
firstObject.objType,
|
|
312
|
+
firstObject.identifiers
|
|
313
|
+
);
|
|
314
|
+
let identifiersConcatSecondObject =
|
|
315
|
+
await identifiersObject.identifiersConcatFromIdentifiers(
|
|
316
|
+
_izContext,
|
|
317
|
+
secondObject.objType,
|
|
318
|
+
secondObject.identifiers
|
|
319
|
+
);
|
|
243
320
|
const firstObjectIdentifiersConcat = `${firstObject.objType.serviceTag}_${firstObject.objType.objectType}__identifiersConcat`;
|
|
244
321
|
const secondObjectIdentifiersConcat = `${secondObject.objType.serviceTag}_${secondObject.objType.objectType}__identifiersConcat`;
|
|
245
322
|
// putItem first Object DynamoDb
|
|
246
|
-
await dynamodbSharedLib.deleteItem(
|
|
323
|
+
await dynamodbSharedLib.deleteItem(
|
|
324
|
+
_izContext,
|
|
247
325
|
await dynamodbSharedLib.tableName(_izContext, tableNameFrom),
|
|
248
326
|
{
|
|
249
327
|
[firstObjectIdentifiersConcat]: identifiersConcatFirstObject,
|
|
250
328
|
[secondObjectIdentifiersConcat]: identifiersConcatSecondObject
|
|
251
329
|
}
|
|
252
|
-
)
|
|
330
|
+
);
|
|
253
331
|
|
|
254
332
|
// put item second Object DynamoDb
|
|
255
|
-
await dynamodbSharedLib.deleteItem(
|
|
333
|
+
await dynamodbSharedLib.deleteItem(
|
|
334
|
+
_izContext,
|
|
256
335
|
await dynamodbSharedLib.tableName(_izContext, tableNameTo),
|
|
257
336
|
{
|
|
258
337
|
[secondObjectIdentifiersConcat]: identifiersConcatSecondObject,
|
|
259
338
|
[firstObjectIdentifiersConcat]: identifiersConcatFirstObject
|
|
260
339
|
}
|
|
261
|
-
)
|
|
340
|
+
);
|
|
262
341
|
}
|
|
263
342
|
}
|
|
264
343
|
|
|
@@ -267,7 +346,8 @@ export default async function deleteRelationship(
|
|
|
267
346
|
await asyncFlowSharedLib.createAwaitingMultipleSteps(
|
|
268
347
|
_izContext,
|
|
269
348
|
awaitingStepIds, // awaitingStepIds
|
|
270
|
-
asyncFlowSharedLib.createPendingStepId(
|
|
349
|
+
asyncFlowSharedLib.createPendingStepId(
|
|
350
|
+
// pendingStepId
|
|
271
351
|
_izContext.uniqueRequestId, // hash id
|
|
272
352
|
PREFIX.deleteRel // prefix, use constant further
|
|
273
353
|
)
|
|
@@ -280,61 +360,94 @@ export default async function deleteRelationship(
|
|
|
280
360
|
relType: relType,
|
|
281
361
|
relId: relId,
|
|
282
362
|
relationshipDirection: relationshipDirection,
|
|
283
|
-
parentFlowId: parentFlowId
|
|
363
|
+
parentFlowId: parentFlowId
|
|
284
364
|
//(<inDeleteRelMessageBody>)
|
|
285
365
|
//(</inDeleteRelMessageBody>)
|
|
286
|
-
}
|
|
366
|
+
};
|
|
287
367
|
_izContext.logger.debug('deleteRelMessageBody: ', deleteRelMessageBody);
|
|
288
368
|
|
|
289
369
|
await Promise.all(
|
|
290
370
|
targetGraphStorageResources.map(async (storageResource) => {
|
|
291
371
|
if (storageResource.storageType === consts.STORAGE_TYPES.graph) {
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
372
|
+
deleteRelMessageBody =
|
|
373
|
+
callingFlowSharedLib.addCallingFlowToSnsRequestMessageObject(
|
|
374
|
+
deleteRelMessageBody,
|
|
375
|
+
callingFlowSharedLib.addParentCallingFlowConfig(
|
|
376
|
+
callingFlowConfig, // receive parent callingFlowConfig.
|
|
377
|
+
callingFlowSharedLib.createCallingFlowConfig(
|
|
378
|
+
// calling flow own service
|
|
379
|
+
//(<callingFlowProperties>)
|
|
380
|
+
await lambdaSharedLib.lambdaFunctionName(
|
|
381
|
+
_izContext,
|
|
382
|
+
TOPIC_NAME_GENERATE_CODE.deleteRelComplete
|
|
383
|
+
),
|
|
384
|
+
{}
|
|
385
|
+
//(</callingFlowProperties>)
|
|
386
|
+
)
|
|
301
387
|
)
|
|
302
|
-
)
|
|
388
|
+
);
|
|
389
|
+
_izContext.logger.debug(
|
|
390
|
+
'messageObject before send message:',
|
|
391
|
+
deleteRelMessageBody
|
|
303
392
|
);
|
|
304
|
-
_izContext.logger.debug("messageObject before send message:", deleteRelMessageBody)
|
|
305
393
|
|
|
306
394
|
let messageToInUpdateRelationship = {
|
|
307
395
|
Message: JSON.stringify(deleteRelMessageBody),
|
|
308
|
-
TopicArn:
|
|
396
|
+
TopicArn: snsSharedLib.snsTopicArnByFlowSchema(
|
|
397
|
+
_izContext,
|
|
398
|
+
TOPIC_NAME_GRAPH_HANDLER.inDeleteRel,
|
|
399
|
+
storageResource.graphServiceTag
|
|
400
|
+
)
|
|
309
401
|
};
|
|
310
|
-
_izContext.logger.debug(
|
|
402
|
+
_izContext.logger.debug(
|
|
403
|
+
'RequestParams before send to sqs messageToInUpdateRelationship ::::::: ',
|
|
404
|
+
messageToInUpdateRelationship
|
|
405
|
+
);
|
|
311
406
|
await sns.publishAsync(_izContext, messageToInUpdateRelationship);
|
|
312
407
|
}
|
|
313
408
|
})
|
|
314
|
-
)
|
|
315
|
-
|
|
409
|
+
);
|
|
316
410
|
} else if (!awaitingStepIds.length) {
|
|
317
|
-
_izContext.logger.debug(
|
|
411
|
+
_izContext.logger.debug('dynamoDb storageResourceTag');
|
|
318
412
|
// if relationshipSchema stored in dynamoDB only will send message to outComplete
|
|
319
413
|
let messageObject = {
|
|
320
414
|
firstObject: firstObject,
|
|
321
415
|
secondObject: secondObject,
|
|
322
416
|
relType: relType,
|
|
323
417
|
relId: relId,
|
|
324
|
-
relationshipDirection
|
|
418
|
+
relationshipDirection
|
|
325
419
|
};
|
|
326
420
|
|
|
327
|
-
if (
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
421
|
+
if (
|
|
422
|
+
callingFlowConfig[callingFlowSharedLib.consts.CALLINGFLOW_PROPERTYNAME]
|
|
423
|
+
) {
|
|
424
|
+
_izContext.logger.debug('have callingFlow');
|
|
425
|
+
messageObject =
|
|
426
|
+
callingFlowSharedLib.addPassBackPropertiesToSnsResponseMessageObject(
|
|
427
|
+
callingFlowConfig,
|
|
428
|
+
messageObject
|
|
429
|
+
);
|
|
430
|
+
|
|
431
|
+
let messageAttributes =
|
|
432
|
+
callingFlowSharedLib.addCallingFlowToSnsResponseMessageAttributes(
|
|
433
|
+
callingFlowConfig,
|
|
434
|
+
{}
|
|
435
|
+
);
|
|
332
436
|
let sendMessageToOutDeleteRelComplete = {
|
|
333
437
|
Message: JSON.stringify(messageObject),
|
|
334
|
-
MessageAttributes: sns.createStringMessageAttributes(
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
438
|
+
MessageAttributes: sns.createStringMessageAttributes(
|
|
439
|
+
_izContext,
|
|
440
|
+
messageAttributes
|
|
441
|
+
),
|
|
442
|
+
TopicArn: snsSharedLib.snsTopicArnByFlowSchema(
|
|
443
|
+
_izContext,
|
|
444
|
+
TOPIC_NAME_GENERATE_CODE.outDeleteRelComplete
|
|
445
|
+
)
|
|
446
|
+
};
|
|
447
|
+
_izContext.logger.debug(
|
|
448
|
+
'send Message to outCreateRelationshipComplete :::',
|
|
449
|
+
sendMessageToOutDeleteRelComplete
|
|
450
|
+
);
|
|
338
451
|
await sns.publishAsync(_izContext, sendMessageToOutDeleteRelComplete);
|
|
339
452
|
}
|
|
340
453
|
}
|
|
@@ -347,10 +460,8 @@ export default async function deleteRelationship(
|
|
|
347
460
|
relationshipDirection,
|
|
348
461
|
errorsFound
|
|
349
462
|
};
|
|
350
|
-
|
|
351
|
-
|
|
352
463
|
} catch (err) {
|
|
353
|
-
_izContext.logger.error('error deleteRelationship: ', err)
|
|
354
|
-
throw
|
|
464
|
+
_izContext.logger.error('error deleteRelationship: ', err);
|
|
465
|
+
throw err;
|
|
355
466
|
}
|
|
356
467
|
}
|
|
@@ -1,20 +1,23 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
middlewareHandler as middleware,
|
|
3
|
+
response
|
|
4
|
+
} from '@izara_project/izara-middleware';
|
|
2
5
|
import callingFlowSharedLib from '@izara_project/izara-core-library-calling-flow';
|
|
3
6
|
|
|
4
7
|
import <%= functionName %> from './<%= mainFileName %>.js';
|
|
5
8
|
|
|
6
9
|
const validatorSchema = {
|
|
7
|
-
|
|
8
|
-
<% if (typeof startConfig !== 'undefined' && startConfig !== null && startConfig.properties && startConfig.properties.length > 0) { -%>
|
|
9
|
-
|
|
10
|
-
|
|
10
|
+
//(<validatorSchema>)
|
|
11
|
+
<% if (typeof startConfig !== 'undefined' && startConfig !== null && startConfig.properties && startConfig.properties.length > 0) { -%>
|
|
12
|
+
type: 'object',
|
|
13
|
+
properties: {
|
|
11
14
|
<% startConfig.properties.forEach(prop => { -%>
|
|
12
|
-
|
|
15
|
+
<%- prop.propertyName %>: { type: '<%- prop.type || 'string' %>' }
|
|
13
16
|
<% }) -%>
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
<% } -%>
|
|
17
|
-
|
|
17
|
+
},
|
|
18
|
+
required: [<%- startConfig.properties.filter(p => p.required !== false).map(p => `'${p.propertyName}'`).join(', ') %>]
|
|
19
|
+
<% } -%>
|
|
20
|
+
//(</validatorSchema>)
|
|
18
21
|
};
|
|
19
22
|
|
|
20
23
|
middleware.setValidatorSchema(validatorSchema, { noAuthorizer: true });
|
|
@@ -24,28 +27,33 @@ middleware.setValidatorSchema(validatorSchema, { noAuthorizer: true });
|
|
|
24
27
|
* Triggered by: API Gateway
|
|
25
28
|
*/
|
|
26
29
|
export const main = middleware.wrap(async (event, context) => {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
return response.success(lambdaFunctionResponse);
|
|
47
|
-
} catch (err) {
|
|
48
|
-
event._izContext?.logger?.error('Unhandled Error in <%= flowStepName %> API:', err);
|
|
49
|
-
return response.failure(err);
|
|
30
|
+
event._izContext?.logger?.debug(
|
|
31
|
+
`[${context.awsRequestId}] Received API request in <%= flowStepName %>`
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
try {
|
|
35
|
+
const passOnProperties = [
|
|
36
|
+
event.body,
|
|
37
|
+
//(<additionalParams>)
|
|
38
|
+
//(</additionalParams>)
|
|
39
|
+
callingFlowSharedLib.addCallingFlowToPassOnProperties(event)
|
|
40
|
+
];
|
|
41
|
+
|
|
42
|
+
const lambdaFunctionResponse = await <%= functionName %>(
|
|
43
|
+
event._izContext,
|
|
44
|
+
...passOnProperties
|
|
45
|
+
);
|
|
46
|
+
|
|
47
|
+
if (lambdaFunctionResponse instanceof Error) {
|
|
48
|
+
return response.failure(lambdaFunctionResponse);
|
|
50
49
|
}
|
|
50
|
+
|
|
51
|
+
return response.success(lambdaFunctionResponse);
|
|
52
|
+
} catch (err) {
|
|
53
|
+
event._izContext?.logger?.error(
|
|
54
|
+
'Unhandled Error in <%= flowStepName %> API:',
|
|
55
|
+
err
|
|
56
|
+
);
|
|
57
|
+
return response.failure(err);
|
|
58
|
+
}
|
|
51
59
|
});
|