@izara_project/izara-market-library-service-schemas 1.0.34 → 1.0.36
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/package.json +1 -1
- package/src/GenerateCodeLibs/src/Consts.js +2 -1
- package/src/GenerateCodeLibs/src/GenerateCodeLibs.js +7 -6
- package/src/MainLibs/src/Consts.js +47 -14
- package/src/MainLibs/src/GenerateCodeUtils.js +2 -0
- package/src/TemplateManager/src/attributeTree/relationshipSchema/data.js +1 -1
- package/src/TemplateManager/src/attributeTreeSchema/generateTemplateData.js +103 -0
- package/src/{reStructure/TemplateData/attributeTreeSchema/mainAttributeTreeSchema → TemplateManager/src/attributeTreeSchema/mainAttributeTree}/attributeLinkTemplate.ejs +3 -7
- package/src/TemplateManager/src/attributeTreeSchema/mainAttributeTree/data.js +134 -0
- package/src/TemplateManager/src/attributeTreeSchema/referenceRelationshipSchema/data.js +84 -0
- package/src/TemplateManager/src/attributeTreeSchema/referenceRelationshipSchema/tempReferenceRelationshipSchema.ejs +9 -0
- package/src/TemplateManager/src/attributeTreeSchema/relationshipSchema/data.js +172 -0
- package/src/TemplateManager/src/attributeTreeSchema/relationshipSchema/template.ejs +7 -0
- package/src/reStructure/GenerateCode.js +1 -0
- package/src/reStructure/SchemaConfig.js +1 -3
- package/src/reStructure/TemplateData/EndpointPerService/handler/api/template.ejs +2 -2
- package/src/reStructure/TemplateData/EndpointPerService/handler/inv/template.ejs +2 -2
- package/src/reStructure/TemplateData/EndpointPerService/mainFunction/create/backupTemplate.ejs +701 -0
- package/src/reStructure/TemplateData/EndpointPerService/mainFunction/create/template.ejs +34 -159
- package/src/reStructure/TemplateData/EndpointPerService/mainFunction/delete/template.ejs +2 -0
- package/src/reStructure/TemplateData/EndpointPerService/mainFunction/get/template.ejs +3 -4
- package/src/reStructure/TemplateData/EndpointPerService/mainFunction/update/template.ejs +2 -0
- package/src/reStructure/TemplateData/externalService/lambdaRole/data.js +38 -12
- package/src/reStructure/TemplateData/externalService/lambdaRole/template.ejs +5 -2
- package/src/reStructure/TemplateData/externalService/snsTopicSubscriptions/data.js +22 -14
- package/src/reStructure/TemplateData/externalService/snsTopicSubscriptions/template.ejs +4 -1
- package/src/reStructure/TemplateData/flowSchema/CreateRecordComplete/functionYaml/data.js +123 -0
- package/src/reStructure/TemplateData/flowSchema/CreateRecordComplete/functionYaml/template.ejs +20 -0
- package/src/reStructure/TemplateData/flowSchema/CreateRecordComplete/handler/data.js +57 -0
- package/src/reStructure/TemplateData/flowSchema/CreateRecordComplete/handler/template.ejs +85 -0
- package/src/reStructure/TemplateData/flowSchema/CreateRecordComplete/mainFunction/data.js +68 -0
- package/src/reStructure/TemplateData/flowSchema/CreateRecordComplete/mainFunction/template.ejs +131 -0
- package/src/reStructure/TemplateData/flowSchema/CreateRecordComplete/queue/data.js +77 -0
- package/src/reStructure/TemplateData/flowSchema/CreateRecordComplete/queue/template.ejs +49 -0
- package/src/reStructure/TemplateData/flowSchema/components/upload/createObject/handler/template.ejs +1 -1
- package/src/reStructure/TemplateData/flowSchema/components/upload/createObjectComplete/mainFunction/template.ejs +1 -1
- package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/createPresignUrl/mainFunction/template.ejs +1 -1
- package/src/reStructure/TemplateData/flowSchema/components/upload/relate/libs/data.js +12 -4
- package/src/reStructure/TemplateData/flowSchema/components/upload/relate/libs/template.ejs +13 -8
- package/src/reStructure/TemplateData/flowSchema/components/websocket/connect/handler/template.ejs +4 -4
- package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/complete/functionYaml/data.js +141 -0
- package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/complete/functionYaml/template.ejs +20 -0
- package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/complete/handler/data.js +55 -0
- package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/complete/handler/template.ejs +83 -0
- package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/complete/mainFunction/data.js +55 -0
- package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/complete/mainFunction/template.ejs +131 -0
- package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/dynamoDB/register.js +82 -0
- package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/sns-in/data.js +64 -0
- package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/sns-in/template.ejs +45 -0
- package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/statusFieldTemplate.ejs +19 -6
- package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/storedCacheTemplate.ejs +9 -15
- package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/subscriptionOutAll/data.js +76 -0
- package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/subscriptionOutAll/template.ejs +13 -0
- package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/wbs/functionYaml/data.js +164 -0
- package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/wbs/functionYaml/template.ejs +18 -0
- package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/wbs/handler/data.js +64 -0
- package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/wbs/handler/template.ejs +88 -0
- package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/wbs/mainFunction/data.js +55 -0
- package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/wbs/mainFunction/template.ejs +222 -0
- package/src/reStructure/TemplateData/flowSchema/dynamoDb/data.js +83 -44
- package/src/reStructure/TemplateData/flowSchema/eventBridge/functionYaml/data.js +26 -59
- package/src/reStructure/TemplateData/flowSchema/eventBridge/functionYaml/template.ejs +3 -3
- package/src/reStructure/TemplateData/flowSchema/eventBridge/handler/inv/data.js +8 -8
- package/src/reStructure/TemplateData/flowSchema/eventBridge/mainFunction/data.js +11 -9
- package/src/reStructure/TemplateData/flowSchema/eventBridge/mainFunction/template.ejs +3 -3
- package/src/reStructure/TemplateData/flowSchema/externalTopic/sns-in-sqs/data.js +5 -9
- package/src/reStructure/TemplateData/flowSchema/externalTopic/sns-in-sqs/template.ejs +1 -7
- package/src/reStructure/TemplateData/flowSchema/externalTopic/sns-out/data.js +2 -3
- package/src/reStructure/TemplateData/flowSchema/externalTopic/sns-out/template.ejs +2 -4
- package/src/reStructure/TemplateData/flowSchema/externalTopic/sqs/functionYaml/data.js +37 -11
- package/src/reStructure/TemplateData/flowSchema/externalTopic/sqs/functionYaml/template.ejs +4 -4
- package/src/reStructure/TemplateData/flowSchema/externalTopic/sqs/handler/data.js +8 -9
- package/src/reStructure/TemplateData/flowSchema/externalTopic/sqs/handler/template.ejs +13 -13
- package/src/reStructure/TemplateData/flowSchema/externalTopic/sqs/mainFunction/data.js +4 -4
- package/src/reStructure/TemplateData/flowSchema/externalTopic/sqs/mainFunction/template.ejs +44 -69
- package/src/reStructure/TemplateData/flowSchema/externalTopic/websocket/functionYaml/data.js +7 -44
- package/src/reStructure/TemplateData/flowSchema/externalTopic/websocket/functionYaml/template.ejs +3 -3
- package/src/reStructure/TemplateData/flowSchema/externalTopic/websocket/handler/data.js +3 -10
- package/src/reStructure/TemplateData/flowSchema/externalTopic/websocket/handler/template.ejs +40 -86
- package/src/reStructure/TemplateData/flowSchema/externalTopic/websocket/mainFunction/data.js +11 -4
- package/src/reStructure/TemplateData/flowSchema/externalTopic/websocket/mainFunction/template.ejs +11 -8
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComplete/functionYaml/data.js +17 -3
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComplete/functionYaml/template.ejs +2 -2
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComplete/mainFunction/data.js +8 -2
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComplete/mainFunction/template.ejs +49 -84
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComponent/functionYaml/data.js +55 -10
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComponent/functionYaml/template.ejs +1 -1
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComponent/handler/data.js +2 -2
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComponent/handler/template.ejs +1 -1
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComponent/mainFunction/data.js +27 -8
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComponent/mainFunction/template.ejs +50 -20
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaCompleteComponent/functionYaml/data.js +20 -5
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaCompleteComponent/functionYaml/template.ejs +1 -1
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaCompleteComponent/handler/data.js +2 -2
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaCompleteComponent/handler/template.ejs +5 -5
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaCompleteComponent/mainFunction/data.js +5 -3
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaCompleteComponent/mainFunction/template.ejs +7 -5
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaComponent/functionYaml/data.js +6 -3
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaComponent/functionYaml/template.ejs +0 -2
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaComponent/handler/data.js +2 -2
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaComponent/handler/template.ejs +3 -3
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaComponent/mainFunction/data.js +9 -9
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaComponent/mainFunction/template.ejs +17 -39
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/sns-in/data.js +14 -8
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/sns-out/data.js +4 -1
- package/src/reStructure/TemplateData/flowSchema/generateTemplateData.js +90 -21
- package/src/reStructure/TemplateData/generateRole/createSharedResource.js +22 -1
- package/src/reStructure/TemplateData/generateRole/sharedResourceTemplate.ejs +3 -0
- package/src/reStructure/TemplateData/perActionComplete/create/mainFunction/template.ejs +9 -8
- package/src/reStructure/TemplateData/perActionComplete/delete/mainFunction/template.ejs +5 -1
- package/src/reStructure/TemplateData/perActionComplete/get/mainFunction/template.ejs +2 -1
- package/src/reStructure/TemplateData/processLogical/mainFunction/template.ejs +1 -0
- package/src/reStructure/TemplateData/propertyValueSchema/generateTemplateData.js +66 -0
- package/src/reStructure/TemplateData/propertyValueSchema/objectPropertyValueSchema/data.js +131 -0
- package/src/reStructure/TemplateData/propertyValueSchema/objectPropertyValueSchema/templateObjectPropertyValueSchema.ejs +16 -0
- package/src/reStructure/TemplateData/propertyValueSchema/relationshipPropertyValueSchema/data.js +156 -0
- package/src/reStructure/TemplateData/propertyValueSchema/relationshipPropertyValueSchema/tempRelationship.ejs +13 -0
- package/src/reStructure/TemplateData/propertyValueSchema/relationshipPropertyValueSchema/templateRelationshipPropertyValueSchema.ejs +7 -0
- package/src/reStructure/TemplateData/relationshipPerAction/create/action/mainFunction/template.ejs +2 -1
- package/src/reStructure/TemplateData/relationshipPerAction/create/complete/mainFunction/template.ejs +2 -1
- package/src/reStructure/TemplateData/relationshipPerAction/delete/action/mainFunction/template.ejs +2 -1
- package/src/reStructure/TemplateData/relationshipPerAction/delete/complete/handler/sqs/template.ejs +5 -5
- package/src/reStructure/TemplateData/relationshipPerAction/delete/complete/mainFunction/template.ejs +5 -4
- package/src/reStructure/TemplateData/relationshipPerAction/get/action/mainFunction/template.ejs +2 -1
- package/src/reStructure/TemplateData/relationshipPerAction/get/complete/handler/sqs/template.ejs +4 -4
- package/src/reStructure/TemplateData/relationshipPerAction/get/complete/mainFunction/template.ejs +4 -3
- package/src/reStructure/TemplateData/relationshipPerAction/update/action/mainFunction/template.ejs +2 -1
- package/src/reStructure/TemplateData/relationshipPerAction/update/complete/mainFunction/template.ejs +2 -1
- package/src/reStructure/TemplateData/resourceYaml/dynamodb/template.ejs +1 -3
- package/src/reStructure/TemplateData/resourceYaml/filterGenerateResource/data.js +61 -0
- package/src/reStructure/TemplateData/resourceYaml/generateTemplateData.js +13 -4
- package/src/reStructure/libs/ValidateAddOnDataStructure.js +62 -0
- package/src/reStructure/TemplateData/attributeTreeSchema/generateTemplateData.js +0 -104
- package/src/reStructure/TemplateData/attributeTreeSchema/mainAttributeTreeSchema/data.js +0 -188
- /package/src/{reStructure/TemplateData/attributeTreeSchema/mainAttributeTreeSchema → TemplateManager/src/attributeTreeSchema/mainAttributeTree}/request.json +0 -0
|
@@ -62,22 +62,11 @@ const { createDataDetailsLib } = require('@izara_project/izara-market-library-se
|
|
|
62
62
|
const { createLinkTypeId, createObjType } = require('@izara_project/izara-core-library-service-schemas/src/Utils');
|
|
63
63
|
const { findLinksByObjTypes } = require("@izara_project/izara-core-library-service-schemas/src/libs/RelSchemaLib")
|
|
64
64
|
const lodash = require("lodash")
|
|
65
|
+
const { createRelTypeConcat } = require('@izara_project/izara-core-library-service-schemas').utils
|
|
66
|
+
const createNodeLib = require('@izara_project/izara-core-library-service-schemas').createNodeLib
|
|
67
|
+
//(<optionalRequire>)
|
|
68
|
+
//(</optionalRequire>)
|
|
65
69
|
|
|
66
|
-
/**
|
|
67
|
-
- all storageType( DB and Graph) use objInstance({identifiers,fields})
|
|
68
|
-
- storageType[DB] async
|
|
69
|
-
- storageType[Graph] sync (should be have lambda complete)
|
|
70
|
-
-- before DB and Graph have boolend check (allStorageTagComplete = true) if storageType == graph set allStorageTagComplete = false,
|
|
71
|
-
and save awaitingMultiplastep prefix(serviceTag_CreateObject{identifierId})
|
|
72
|
-
|
|
73
|
-
>>> in lambdaComplete resive message from GrapHandler
|
|
74
|
-
1.1 check have returnValue.errorsFould.length > 0
|
|
75
|
-
-- Delete all awitingMultiplestep and senf message to callingFlow have errorFound.
|
|
76
|
-
1.2 check awaitingmultipleStepall finish
|
|
77
|
-
-- Delete awaitingStep in come if have other multiplestep(not finish)== not send message.
|
|
78
|
-
--- if check awaitingmultipleStepall finish not have record ===> sendmessage to callingFlow.
|
|
79
|
-
*/
|
|
80
|
-
//=========================================================================================
|
|
81
70
|
/**
|
|
82
71
|
*
|
|
83
72
|
* @param {*} _izContext
|
|
@@ -128,153 +117,23 @@ module.exports.createMain = async (
|
|
|
128
117
|
let createDataDetails = await createDataDetailsLib(_izContext, objectSchemas);
|
|
129
118
|
_izContext.logger.debug("createDataDetails is =", createDataDetails);
|
|
130
119
|
|
|
131
|
-
let checkCorrectLinks = [];
|
|
132
|
-
|
|
133
|
-
//validate linkType
|
|
134
120
|
if ((requestParams.hasOwnProperty("relationships")) && (requestParams.relationships.length > 0)) {
|
|
121
|
+
//(<beforeValidateRelationships>)
|
|
122
|
+
//(</beforeValidateRelationships>)
|
|
135
123
|
|
|
136
|
-
|
|
137
|
-
_izContext.logger.debug("relationshipProperties", relationshipProperties);
|
|
138
|
-
_izContext.logger.debug("relType", relationshipProperties.relType);
|
|
139
|
-
let getObjectRelationship = await getObjectSchema.getRelationshipSchemaWithCache(
|
|
140
|
-
_izContext,
|
|
141
|
-
relationshipProperties.relType
|
|
142
|
-
)
|
|
143
|
-
_izContext.logger.debug("getObjectRelationship", getObjectRelationship)
|
|
144
|
-
|
|
145
|
-
for (const relationshipLink of Object.values(getObjectRelationship.links)) {
|
|
146
|
-
if (relationshipLink.from.linkType === "many" && relationshipLink.to.linkType === "many") {
|
|
147
|
-
if (relationshipLink.from.requiredOnCreate === true || relationshipLink.to.requiredOnCreate === true) {
|
|
148
|
-
errorsFound.push("error many to many linkType can't have requireOnCreate === true")
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
const links = await findLinksByObjTypes(_izContext, [objType, relationshipProperties.targetObjType], getObjectRelationship.links);
|
|
153
|
-
_izContext.logger.debug("links", links)
|
|
154
|
-
|
|
155
|
-
if (!links.length) {
|
|
156
|
-
errorsFound.push(`not found link between ${JSON.stringify({ mainObjType: objType })} and ${JSON.stringify({ toObjType: relationshipProperties.targetObjType })} `)
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
for (let link of links) {
|
|
160
|
-
const { serviceTag: fromServiceTag, objectType: fromObjectType } = objType;
|
|
161
|
-
const { serviceTag: toServiceTag, objectType: toObjectType } = relationshipProperties.targetObjType
|
|
162
|
-
|
|
163
|
-
const { serviceTag: firstServiceTag, objectType: firstObjectType } = link.from.objType;
|
|
164
|
-
const { serviceTag: secondServiceTag, objectType: secondObjectType } = link.to.objType
|
|
165
|
-
|
|
166
|
-
const matchesFromTo =
|
|
167
|
-
fromServiceTag === firstServiceTag && fromObjectType === firstObjectType &&
|
|
168
|
-
toServiceTag === secondServiceTag && toObjectType === secondObjectType;
|
|
169
|
-
|
|
170
|
-
const matchesToFrom =
|
|
171
|
-
fromServiceTag === secondServiceTag && fromObjectType === secondObjectType &&
|
|
172
|
-
toServiceTag === firstServiceTag && toObjectType === firstObjectType
|
|
173
|
-
|
|
174
|
-
if ((relationshipProperties.relationshipDirection === "from" && matchesFromTo) ||
|
|
175
|
-
(relationshipProperties.relationshipDirection === "to" && matchesToFrom)) {
|
|
176
|
-
checkCorrectLinks.push(true)
|
|
177
|
-
} else {
|
|
178
|
-
checkCorrectLinks.push(false)
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
for (const [index, checkCorrectLink] of checkCorrectLinks.entries()) {
|
|
184
|
-
if (checkCorrectLink === false) {
|
|
185
|
-
errorsFound.push(`relationship direction ${JSON.stringify(requestParams.relationships[index])} is invalid`)
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
_izContext.logger.debug("finish validate Relationships from RequestParams")
|
|
189
|
-
let requiredOnCreateLinks = {};
|
|
190
|
-
let createLinkTypeIds = [];
|
|
191
|
-
// validate relationships link
|
|
192
|
-
let objectRelationshipSchema = await getObjectSchema.getRequiredOnCreateLinksWithCache(_izContext, objType);
|
|
193
|
-
_izContext.logger.debug("objectRelationshipSchema", objectRelationshipSchema);
|
|
194
|
-
|
|
195
|
-
// validate requiredOnCreateLinks
|
|
196
|
-
let filteredRequiredOnCreatedLinks = [];
|
|
197
|
-
|
|
198
|
-
await Promise.all(
|
|
199
|
-
objectRelationshipSchema.map(async (requiredLink) => {
|
|
200
|
-
const serviceTag = await Promise.all(
|
|
201
|
-
requiredLink.storageResourceTags.map(async (storageTag) => {
|
|
202
|
-
let storageResource = requiredLink.storageResources[storageTag];
|
|
203
|
-
if (storageResource.storageType === consts.STORAGE_TYPES.graph) {
|
|
204
|
-
return await getGraphServiceTagWithCache(_izContext, storageResource.graphServerTag);
|
|
205
|
-
}
|
|
206
|
-
})
|
|
207
|
-
);
|
|
208
|
-
})
|
|
209
|
-
)
|
|
210
|
-
_izContext.logger.debug("filteredRequiredOnCreatedLinks", filteredRequiredOnCreatedLinks);
|
|
211
|
-
|
|
212
|
-
if (filteredRequiredOnCreatedLinks.length) {
|
|
213
|
-
if (!requestParams.relationships || !requestParams.relationships.length) {
|
|
214
|
-
// in case not send relationship to create with
|
|
215
|
-
for (const requireLink of filteredRequiredOnCreatedLinks) {
|
|
216
|
-
errorsFound.push(`missing required relationship of relType ${JSON.stringify(requireLink.relType)} when create`)
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
for (const requireLink of filteredRequiredOnCreatedLinks) {
|
|
221
|
-
const requiredOnCreateLinkTypeId = createLinkTypeId(
|
|
222
|
-
_izContext,
|
|
223
|
-
objType,
|
|
224
|
-
requireLink.other.objType,
|
|
225
|
-
requireLink.relType,
|
|
226
|
-
requireLink.base.direction
|
|
227
|
-
);
|
|
228
|
-
|
|
229
|
-
Object.assign(requiredOnCreateLinks, {
|
|
230
|
-
[requiredOnCreateLinkTypeId]: requireLink
|
|
231
|
-
})
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
if (requestParams.hasOwnProperty("relationships") && requestParams.relationships.length) {
|
|
235
|
-
for (const createRelationship of requestParams.relationships) {
|
|
236
|
-
const onCreateLinkTypeId = createLinkTypeId(
|
|
237
|
-
_izContext,
|
|
238
|
-
objType,
|
|
239
|
-
createRelationship.targetObjType,
|
|
240
|
-
createRelationship.relType,
|
|
241
|
-
createRelationship.relationshipDirection
|
|
242
|
-
);
|
|
243
|
-
|
|
244
|
-
if (!requiredOnCreateLinks.hasOwnProperty(onCreateLinkTypeId)) {
|
|
245
|
-
errorsFound.push(`relType:${JSON.stringify(createRelationship.relType)} not allow to create when use create action`)
|
|
246
|
-
continue;
|
|
247
|
-
} else {
|
|
248
|
-
createLinkTypeIds.push(onCreateLinkTypeId);
|
|
249
|
-
}
|
|
250
|
-
}
|
|
251
|
-
}
|
|
124
|
+
errorsFound.push(...await createNodeLib.validateRequiredOnCreateLinks(_izContext, objType, requestParams.relationships))
|
|
252
125
|
}
|
|
126
|
+
_izContext.logger.debug("errorsFound", errorsFound)
|
|
253
127
|
|
|
254
|
-
|
|
255
|
-
// validate missing relType when create that should create
|
|
256
|
-
const remainRequiredOnCreateLinkTypeIds = Object.keys(requiredOnCreateLinks)
|
|
257
|
-
.filter(requiredInCreateLinkTypeId => !createLinkTypeIds.includes(requiredInCreateLinkTypeId))
|
|
258
|
-
|
|
259
|
-
if (remainRequiredOnCreateLinkTypeIds.length) {
|
|
260
|
-
for (const remainRequiredOnCreateLinkTypeId of remainRequiredOnCreateLinkTypeIds) {
|
|
261
|
-
const missingLink = {
|
|
262
|
-
relType: requiredOnCreateLinks[remainRequiredOnCreateLinkTypeId].relType,
|
|
263
|
-
base: requiredOnCreateLinks[remainRequiredOnCreateLinkTypeId].base.objType,
|
|
264
|
-
other: requiredOnCreateLinks[remainRequiredOnCreateLinkTypeId].other.objType
|
|
265
|
-
};
|
|
266
|
-
errorsFound.push(`Missing Link:: ${JSON.stringify(missingLink)} when create`)
|
|
267
|
-
}
|
|
268
|
-
}
|
|
269
|
-
_izContext.logger.debug("createLinkTypeIds", createLinkTypeIds);
|
|
270
|
-
_izContext.logger.debug("requiredOnCreateLinks", requiredOnCreateLinks);
|
|
271
128
|
// end validate
|
|
272
|
-
|
|
273
129
|
let objInstanceFull = {
|
|
274
130
|
identifiers: {},
|
|
275
131
|
fields: {}
|
|
276
132
|
};
|
|
277
133
|
|
|
134
|
+
//(<optionalObjInstanceFull>)
|
|
135
|
+
//(</optionalObjInstanceFull>)
|
|
136
|
+
|
|
278
137
|
let listOfRequiredOnCreate = [];
|
|
279
138
|
let listOfOptionalOnCreate = [];
|
|
280
139
|
|
|
@@ -401,8 +260,11 @@ module.exports.createMain = async (
|
|
|
401
260
|
if (errorsFound.length == 0) {
|
|
402
261
|
|
|
403
262
|
for (let [storageTag, createDataDetail] of Object.entries(createDataDetails)) {
|
|
404
|
-
|
|
263
|
+
//(<beforeCreate>)
|
|
264
|
+
//(</beforeCreate>)
|
|
405
265
|
if (createDataDetail.storageType == consts.STORAGE_TYPES.dynamoDB) {
|
|
266
|
+
//(<beforeCreateRecordDynamo>)
|
|
267
|
+
//(</beforeCreateRecordDynamo>)
|
|
406
268
|
_izContext.logger.debug("::::::DynamoDB::::::", { storageTag, objInstanceFull });
|
|
407
269
|
|
|
408
270
|
|
|
@@ -429,6 +291,8 @@ module.exports.createMain = async (
|
|
|
429
291
|
}
|
|
430
292
|
);
|
|
431
293
|
} else if (createDataDetail.storageType == consts.STORAGE_TYPES.graph) {
|
|
294
|
+
//(<beforeCreateNode>)
|
|
295
|
+
//(</beforeCreateNode>)
|
|
432
296
|
_izContext.logger.debug("::::::Graph::::::", { storageTag, objInstanceFull });
|
|
433
297
|
|
|
434
298
|
Object.assign(objInstanceFullForGraph.fields, createObjInstanceFullFieldsByStorageTag(_izContext, storageTag, createDataDetail))
|
|
@@ -497,7 +361,8 @@ module.exports.createMain = async (
|
|
|
497
361
|
});
|
|
498
362
|
|
|
499
363
|
if (objecForCreate.allStorageTagComplete == false) { // needless check because in listOfObjectForCreates push case graph only!
|
|
500
|
-
|
|
364
|
+
//(<beforeSendMessageToGraph>)
|
|
365
|
+
//(</beforeSendMessageToGraph>)
|
|
501
366
|
messageObject = {
|
|
502
367
|
objType: objType,
|
|
503
368
|
objInstanceFull: objecForCreate.objInstanceFull,
|
|
@@ -531,6 +396,16 @@ module.exports.createMain = async (
|
|
|
531
396
|
};
|
|
532
397
|
_izContext.logger.debug("RequestParams before send to sqs messageToCreateObject ::::::: ", messageToCreateObject);
|
|
533
398
|
await sns.publishAsync(_izContext, messageToCreateObject);
|
|
399
|
+
|
|
400
|
+
//(<afterSendMessageToGraph>)
|
|
401
|
+
//(</afterSendMessageToGraph>)
|
|
402
|
+
return {
|
|
403
|
+
objType: objType,
|
|
404
|
+
objInstanceFull: objInstanceFullForGraph,
|
|
405
|
+
relationships: requestParams.relationships || [],
|
|
406
|
+
status: "complete",
|
|
407
|
+
errorsFound: errorsFound
|
|
408
|
+
}
|
|
534
409
|
};
|
|
535
410
|
}; // end loop of objectCreate.
|
|
536
411
|
if (errorsFound.length > 0) {
|
|
@@ -571,8 +446,8 @@ module.exports.createMain = async (
|
|
|
571
446
|
|
|
572
447
|
return {
|
|
573
448
|
objType: objType,
|
|
574
|
-
|
|
575
|
-
|
|
449
|
+
objInstanceFull: objInstanceFull,
|
|
450
|
+
relationships: requestParams.relationships || [],
|
|
576
451
|
status: "error",
|
|
577
452
|
errorsFound: errorsFound
|
|
578
453
|
}
|
|
@@ -609,8 +484,8 @@ module.exports.createMain = async (
|
|
|
609
484
|
}
|
|
610
485
|
return {
|
|
611
486
|
objType: objType,
|
|
612
|
-
|
|
613
|
-
|
|
487
|
+
objInstanceFull: objInstanceFullForDynamoDb,
|
|
488
|
+
relationships: requestParams.relationships || [],
|
|
614
489
|
status: "complete",
|
|
615
490
|
errorsFound: errorsFound
|
|
616
491
|
}
|
|
@@ -618,4 +493,4 @@ module.exports.createMain = async (
|
|
|
618
493
|
} catch (err) {
|
|
619
494
|
throw (err)
|
|
620
495
|
}
|
|
621
|
-
}
|
|
496
|
+
}
|
|
@@ -50,6 +50,8 @@ const { TOPIC_NAME_GENERATE_CODE, TOPIC_NAME_GRAPH_HANDLER } = require('@izara_p
|
|
|
50
50
|
const { createDeleteDataDetail } = require('@izara_project/izara-market-library-service-schemas/src/GenerateCodeLibs/src/GenerateCodeLibs')
|
|
51
51
|
const { createObjType } = require("@izara_project/izara-core-library-service-schemas/src/Utils");
|
|
52
52
|
|
|
53
|
+
//(<optionalRequire>)
|
|
54
|
+
//(</optionalRequire>)
|
|
53
55
|
/**
|
|
54
56
|
*
|
|
55
57
|
* @param {*} _izContext
|
|
@@ -53,6 +53,8 @@ const sns = externalRequest.sns
|
|
|
53
53
|
const NoRetryError = require('@izara_project/izara-core-library-core/src/NoRetryError');
|
|
54
54
|
const { TOPIC_NAME_GENERATE_CODE } = require('@izara_project/izara-market-library-service-schemas/src/GenerateCodeLibs/src/Consts');
|
|
55
55
|
const coreConsts = require("@izara_project/izara-core-library-core/src/Consts");
|
|
56
|
+
//(<optionalRequire>)
|
|
57
|
+
//(</optionalRequire>)
|
|
56
58
|
/**
|
|
57
59
|
*
|
|
58
60
|
*
|
|
@@ -149,10 +151,7 @@ module.exports.getMain = async (
|
|
|
149
151
|
if (callingFlowConfig[callingFlowSharedLib.consts.CALLINGFLOW_PROPERTYNAME]) {
|
|
150
152
|
|
|
151
153
|
let messageObject = {
|
|
152
|
-
objType:
|
|
153
|
-
objectType: OBJECT_TYPE,
|
|
154
|
-
serviceTag: SERVICE_TAG
|
|
155
|
-
},
|
|
154
|
+
objType: objType,
|
|
156
155
|
objInstanceFull: dataFromGraph.objInstanceFull
|
|
157
156
|
}
|
|
158
157
|
// send message to SNS ProcessFindRequiredData
|
|
@@ -40,6 +40,8 @@ const { createUpdateDataDetail } = require("@izara_project/izara-market-library-
|
|
|
40
40
|
const { PREFIX, TOPIC_NAME_GENERATE_CODE, TOPIC_NAME_GRAPH_HANDLER } = require('@izara_project/izara-market-library-service-schemas/src/GenerateCodeLibs/src/Consts');
|
|
41
41
|
const coreConsts = require('@izara_project/izara-core-library-core/src/Consts')
|
|
42
42
|
const { createObjType } = require("@izara_project/izara-core-library-service-schemas/src/Utils")
|
|
43
|
+
//(<optionalRequire>)
|
|
44
|
+
//(</optionalRequire>)
|
|
43
45
|
/**
|
|
44
46
|
*
|
|
45
47
|
*
|
|
@@ -75,23 +75,26 @@ const createExternalLambdaRole = async (_izContext, allObjSchemas, allRelSchemas
|
|
|
75
75
|
if (event.includes("s3")) {
|
|
76
76
|
const externalLambdaIamRoleGetPresignUrl = await externalLambdaIamRoleUploadS3(_izContext);
|
|
77
77
|
externalLambdaIamRoleGetPresignUrl && externalLambdaIamRoleArray.push(externalLambdaIamRoleGetPresignUrl);
|
|
78
|
+
} else if (event.includes("extTopic")) {
|
|
79
|
+
const externalSnsPublish = await externalRoleSnsPublish(_izContext, localFlowSchema);
|
|
80
|
+
externalSnsPublish && externalLambdaIamRoleArray.push(externalSnsPublish);
|
|
78
81
|
}
|
|
79
82
|
}
|
|
80
83
|
}
|
|
81
|
-
}
|
|
82
84
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
85
|
+
// console.log("externalLambdaIamRoleArray", externalLambdaIamRoleArray)
|
|
86
|
+
// console.log("createSourceArrayIamRole", JSON.stringify(externalLambdaIamRoleArray))
|
|
87
|
+
// return externalLambdaIamRoleArray
|
|
86
88
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
89
|
+
return {
|
|
90
|
+
templatePath: templatePath,
|
|
91
|
+
templateData: { datas: externalLambdaIamRoleArray },
|
|
92
|
+
setting: {
|
|
93
|
+
savePath: path.join(srcPath, SOURCE_PATH.externalService),
|
|
94
|
+
saveFileName: SAVE_FILE_NAME.externalLambdaRole,
|
|
95
|
+
fileExtension: ".js",
|
|
96
|
+
isAppend: false
|
|
97
|
+
}
|
|
95
98
|
}
|
|
96
99
|
}
|
|
97
100
|
}
|
|
@@ -274,4 +277,27 @@ function externalLambdaIamRoleUploadS3(_izContext) {
|
|
|
274
277
|
}
|
|
275
278
|
}
|
|
276
279
|
|
|
280
|
+
async function externalRoleSnsPublish(_izContext, localFlowSchema) {
|
|
281
|
+
|
|
282
|
+
const additionalResourcePermission = [];
|
|
283
|
+
const flowStepInSplitKey = Object.keys(localFlowSchema.flowSteps)[0].split('_')
|
|
284
|
+
const serviceTag = flowStepInSplitKey[0]
|
|
285
|
+
|
|
286
|
+
additionalResourcePermission.push(
|
|
287
|
+
createIamRole(
|
|
288
|
+
{
|
|
289
|
+
[RESOURCE_CLASSES.sns]: [SNS_RESOURCE.publish]
|
|
290
|
+
},
|
|
291
|
+
[
|
|
292
|
+
externalResourceName(RESOURCE_CLASSES.sns, `${flowStepInSplitKey[2]}_${flowStepInSplitKey[3]}`, serviceTag)
|
|
293
|
+
]
|
|
294
|
+
)
|
|
295
|
+
)
|
|
296
|
+
|
|
297
|
+
return {
|
|
298
|
+
additionalResourcePermission,
|
|
299
|
+
objectType: SOURCE_GENERATE_IAM_ROLE.ExternalTopicRole,
|
|
300
|
+
};
|
|
301
|
+
}
|
|
302
|
+
|
|
277
303
|
module.exports = createExternalLambdaRole;
|
|
@@ -47,10 +47,13 @@ module.exports.generatedLambdaRole = async () => {
|
|
|
47
47
|
]
|
|
48
48
|
<%_ }) _%>
|
|
49
49
|
<%_ }) _%>
|
|
50
|
-
}
|
|
50
|
+
},<% if(resourceIdx < data.additionalResourcePermission.length-1) {_%>, <%_ } %>
|
|
51
51
|
<%_ }) _%>
|
|
52
|
+
//(<create<%- data.objectType%>Role>)
|
|
53
|
+
//(</create<%- data.objectType%>Role>)
|
|
52
54
|
]
|
|
53
|
-
},
|
|
55
|
+
},
|
|
56
|
+
<%_ }) %>
|
|
54
57
|
]
|
|
55
58
|
return externalLambdaRole
|
|
56
59
|
}
|
|
@@ -79,6 +79,8 @@ const createExternalSnsSubscriptions = async (_izContext, allObjSchemas, allRelS
|
|
|
79
79
|
const snsServiceConfigForExtTopic = await snsSubscriptionFlowSchemaExternalTopic(_izContext, localFlowSchema);
|
|
80
80
|
snsServiceConfigForExtTopic && snsServiceConfigArray.push(snsServiceConfigForExtTopic);
|
|
81
81
|
}
|
|
82
|
+
const snsServiceConfigForCreateRecordByStatusType = await createFlowSchemaRegisterSnsTopicSubscriptions(_izContext, localFlowSchema);
|
|
83
|
+
snsServiceConfigForCreateRecordByStatusType && snsServiceConfigArray.push(snsServiceConfigForCreateRecordByStatusType);
|
|
82
84
|
}
|
|
83
85
|
}
|
|
84
86
|
}
|
|
@@ -181,21 +183,27 @@ function snsSubscriptionConfirmReserved(_izContext) {
|
|
|
181
183
|
}
|
|
182
184
|
|
|
183
185
|
function snsSubscriptionFlowSchemaExternalTopic(_izContext, localFlowSchema) {
|
|
184
|
-
const
|
|
185
|
-
const
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
sqsEndpoint: splitFlowStepKey[3]
|
|
195
|
-
};
|
|
196
|
-
}
|
|
186
|
+
const flowStepOut = Object.keys(localFlowSchema.flowSteps)[1]
|
|
187
|
+
const splitFlowStepOutKey = flowStepOut.split("_");
|
|
188
|
+
const queueNameExtTopic = upperCase(FUNCTION_NAME.flowSchemaExternalTopic)
|
|
189
|
+
|
|
190
|
+
return {
|
|
191
|
+
serviceTag: [splitFlowStepOutKey[0]],
|
|
192
|
+
topicName: splitFlowStepOutKey[2] + '_' + splitFlowStepOutKey[3],
|
|
193
|
+
sqsEndpoint: queueNameExtTopic
|
|
194
|
+
};
|
|
195
|
+
}
|
|
197
196
|
|
|
198
|
-
|
|
197
|
+
function createFlowSchemaRegisterSnsTopicSubscriptions(_izContext, localFlowSchema) {
|
|
198
|
+
const flowStepKeys = Object.keys(localFlowSchema.flowSteps)[1];
|
|
199
|
+
const flowStepKeySplit = flowStepKeys.split("_");
|
|
200
|
+
const registerCompleteSqs = upperCase(FUNCTION_NAME.flowSchemaRegister);
|
|
201
|
+
|
|
202
|
+
return {
|
|
203
|
+
serviceTag: [flowStepKeySplit[0]],
|
|
204
|
+
topicName: flowStepKeySplit[2],
|
|
205
|
+
sqsEndpoint: registerCompleteSqs,
|
|
206
|
+
}
|
|
199
207
|
}
|
|
200
208
|
|
|
201
209
|
module.exports = createExternalSnsSubscriptions;
|
|
@@ -0,0 +1,123 @@
|
|
|
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
|
+
'use strict';
|
|
19
|
+
const path = require('path');
|
|
20
|
+
|
|
21
|
+
const { FLOW_SCHEMA_HOOK_STATE, ACTIONS, HANDLER } = require('@izara_project/izara-core-library-service-schemas/src/Consts')
|
|
22
|
+
const { firstLetterUpperCase: upperCase } = require('../../../../../MainLibs/src/Utils')
|
|
23
|
+
const {
|
|
24
|
+
SOURCE_PATH,
|
|
25
|
+
defaultIamRolePerAction,
|
|
26
|
+
createIamRole,
|
|
27
|
+
RESOURCE_CLASSES,
|
|
28
|
+
SNS_RESOURCE,
|
|
29
|
+
resourceNames,
|
|
30
|
+
DYNAMO_RESOURCE,
|
|
31
|
+
SAVE_FILE_NAME,
|
|
32
|
+
FUNCTION_NAME,
|
|
33
|
+
shortNameHandler,
|
|
34
|
+
externalResourceYaml,
|
|
35
|
+
SOURCE_GENERATE_IAM_ROLE,
|
|
36
|
+
FLOW_SCHEMA_EVENT_TYPE
|
|
37
|
+
} = require('../../../../../MainLibs/src/Consts');
|
|
38
|
+
|
|
39
|
+
const templatePath = path.join(__dirname, "template.ejs");
|
|
40
|
+
/**
|
|
41
|
+
* receive objectSchema
|
|
42
|
+
* create data for WebScoket handler template
|
|
43
|
+
*
|
|
44
|
+
* @param {Object} objectSchema
|
|
45
|
+
* @return {{templatePath, templateData,setting}}
|
|
46
|
+
*/
|
|
47
|
+
|
|
48
|
+
function data(_izContext, flowSchema, srcPath) {
|
|
49
|
+
return [createSourceParams(_izContext, flowSchema, srcPath)]
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function createSourceParams(_izContext, flowSchema, srcPath) {
|
|
53
|
+
let functionName = upperCase(FUNCTION_NAME.createRecordComplete) + upperCase(flowSchema.flowTag)
|
|
54
|
+
let handlerType = upperCase(HANDLER.hdrSqs)
|
|
55
|
+
let additionalResourcePermission = defaultIamRolePerAction();
|
|
56
|
+
let flowSteps = Object.keys(flowSchema.flowSteps)
|
|
57
|
+
// let splitFlowSteps = flowSteps[0].split("_")
|
|
58
|
+
let topicArn;
|
|
59
|
+
// let serviceTag;
|
|
60
|
+
for (const event of flowSchema.event) {
|
|
61
|
+
if (event.includes(FLOW_SCHEMA_EVENT_TYPE.ownTopic)) {
|
|
62
|
+
topicArn = flowSteps[0]
|
|
63
|
+
} else {
|
|
64
|
+
return
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
additionalResourcePermission.push(
|
|
69
|
+
createIamRole(
|
|
70
|
+
{
|
|
71
|
+
[RESOURCE_CLASSES.sns]: [SNS_RESOURCE.publish]
|
|
72
|
+
},
|
|
73
|
+
[
|
|
74
|
+
resourceNames(RESOURCE_CLASSES.sns, topicArn)
|
|
75
|
+
]
|
|
76
|
+
)
|
|
77
|
+
)
|
|
78
|
+
|
|
79
|
+
additionalResourcePermission.push(
|
|
80
|
+
createIamRole(
|
|
81
|
+
{
|
|
82
|
+
[RESOURCE_CLASSES.dynamoDbTable]: [DYNAMO_RESOURCE.updateItem]
|
|
83
|
+
},
|
|
84
|
+
[
|
|
85
|
+
resourceNames(RESOURCE_CLASSES.dynamoDbTable, "WebSocketTask")
|
|
86
|
+
]
|
|
87
|
+
)
|
|
88
|
+
)
|
|
89
|
+
// external lambda role
|
|
90
|
+
// if (serviceTag) {
|
|
91
|
+
// additionalResourcePermission.push(
|
|
92
|
+
// createIamRole(
|
|
93
|
+
// {
|
|
94
|
+
// [RESOURCE_CLASSES.sns]: [SNS_RESOURCE.publish]
|
|
95
|
+
// },
|
|
96
|
+
// [
|
|
97
|
+
// externalResourceYaml(RESOURCE_CLASSES.sns, topicArn, serviceTag)
|
|
98
|
+
// ]
|
|
99
|
+
// )
|
|
100
|
+
// )
|
|
101
|
+
// }
|
|
102
|
+
console.log({ additionalResourcePermission: JSON.stringify(additionalResourcePermission, null, 2) })
|
|
103
|
+
|
|
104
|
+
return {
|
|
105
|
+
templatePath: templatePath,
|
|
106
|
+
templateData: {
|
|
107
|
+
resourceLocation: path.join(SOURCE_PATH.resourceLocationCreateRecordComplete, flowSchema.flowTag, "source/"),
|
|
108
|
+
functionName,
|
|
109
|
+
handlerType,
|
|
110
|
+
additionalResourcePermission,
|
|
111
|
+
functionNameConfig: upperCase(functionName) + upperCase(shortNameHandler(handlerType)),
|
|
112
|
+
roleName: SOURCE_GENERATE_IAM_ROLE.CreateRecordComplete
|
|
113
|
+
},
|
|
114
|
+
setting: {
|
|
115
|
+
savePath: path.join(srcPath, SOURCE_PATH.appYaml),
|
|
116
|
+
saveFileName: upperCase(SAVE_FILE_NAME.flowSchema),
|
|
117
|
+
fileExtension: ".yml",
|
|
118
|
+
isAppend: true
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
module.exports = data;
|
package/src/reStructure/TemplateData/flowSchema/CreateRecordComplete/functionYaml/template.ejs
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
<%_ const join = require('path').join; _%>
|
|
2
|
+
<%- firstLetterUpperCase(functionNameConfig) %>:
|
|
3
|
+
handler: <%- join(resourceLocation, `${firstLetterUpperCase(functionName)}_${firstLetterUpperCase(handlerType)}.main`)%>
|
|
4
|
+
name: ${self:custom.iz_resourcePrefix}<%- firstLetterUpperCase(functionName) %><%- firstLetterUpperCase(handlerType) %>
|
|
5
|
+
events:
|
|
6
|
+
- sqs:
|
|
7
|
+
arn: arn:aws:sqs:${self:custom.iz_region}:${self:custom.iz_accountId}:${self:custom.iz_resourcePrefix}<%- functionName %>
|
|
8
|
+
batchSize: 10
|
|
9
|
+
filterPatterns: #**** need to update serverless framwork upper v.2.69.1
|
|
10
|
+
- body: {"MessageAttributes":{"callingFlow":{"Value":["${self:custom.iz_resourcePrefix}<%- functionName %>"]}}} # functionName of callingFlow
|
|
11
|
+
- body: {"MessageAttributes":{"callingFlow":{"Value":[{"exists":false}]}}}
|
|
12
|
+
role: <%- roleName %>Role
|
|
13
|
+
#<#<%- functionName %><%- handlerType %>IamRole#>
|
|
14
|
+
#<#/<%- functionName %><%- handlerType %>IamRole#>
|
|
15
|
+
<%_ function firstLetterUpperCase(text){
|
|
16
|
+
return text.charAt(0).toUpperCase() + text.slice(1)
|
|
17
|
+
} _%>
|
|
18
|
+
<%_ function firstLetterLowerCase(str) {
|
|
19
|
+
return str.charAt(0).toLowerCase() + str.slice(1)
|
|
20
|
+
} _%>
|
|
@@ -0,0 +1,57 @@
|
|
|
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
|
+
'use strict';
|
|
19
|
+
const path = require('path');
|
|
20
|
+
const { FLOW_SCHEMA_HOOK_STATE, HANDLER } = require('@izara_project/izara-core-library-service-schemas/src/Consts')
|
|
21
|
+
const { SOURCE_PATH, FUNCTION_NAME } = require('../../../../../MainLibs/src/Consts');
|
|
22
|
+
const { firstLetterLowerCase: lowerCase, firstLetterUpperCase: upperCase } = require("../../../../../MainLibs/src/Utils")
|
|
23
|
+
const templatePath = path.join(__dirname, "template.ejs")
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* receive objectSchema
|
|
27
|
+
* create data for WebScoket handler template
|
|
28
|
+
*
|
|
29
|
+
* @param {Object} objectSchema
|
|
30
|
+
* @return {{templatePath, templateData,setting}}
|
|
31
|
+
*/
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
function data(_izContext, flowSchema, srcPath) {
|
|
35
|
+
return [createParamsForCreateSource(_izContext, flowSchema, srcPath)]
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function createParamsForCreateSource(_izContext, flowSchema, srcPath) {
|
|
39
|
+
let functionName = upperCase(FUNCTION_NAME.createRecordComplete);
|
|
40
|
+
let handlerType = upperCase(HANDLER.hdrSqs)
|
|
41
|
+
let queueName = upperCase(FUNCTION_NAME.createRecordComplete) + upperCase(flowSchema.flowTag) + upperCase(HANDLER.hdrSqs)
|
|
42
|
+
return {
|
|
43
|
+
templatePath: templatePath,
|
|
44
|
+
templateData: {
|
|
45
|
+
functionName,
|
|
46
|
+
handlerType,
|
|
47
|
+
queueName
|
|
48
|
+
},
|
|
49
|
+
setting: {
|
|
50
|
+
savePath: path.join(srcPath, SOURCE_PATH.createRecordComplete, flowSchema.flowTag, 'source/'),
|
|
51
|
+
saveFileName: `${functionName}_${handlerType}`,
|
|
52
|
+
fileExtension: ".js",
|
|
53
|
+
isAppend: false
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
module.exports = data
|