@izara_project/izara-market-library-service-schemas 1.0.6 → 1.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (20) hide show
  1. package/package.json +1 -1
  2. package/src/TemplateManager/src/FindData/mainFunction/template.ejs +3 -0
  3. package/src/TemplateManager/src/GenerateCode.js +20 -14
  4. package/src/TemplateManager/src/OutPerActionComplete/OutCreateComplete/functionYaml/data.js +1 -1
  5. package/src/TemplateManager/src/OutPerActionComplete/OutCreateComplete/handler/data.js +59 -0
  6. package/src/TemplateManager/src/OutPerActionComplete/OutCreateComplete/handler/template.ejs +129 -0
  7. package/src/TemplateManager/src/OutPerActionComplete/OutCreateComplete/mainFunction/data.js +53 -0
  8. package/src/TemplateManager/src/OutPerActionComplete/OutCreateComplete/mainFunction/template.ejs +172 -0
  9. package/src/TemplateManager/src/OutPerActionComplete/OutCreateComplete/sns-in-sqs/data.js +58 -0
  10. package/src/TemplateManager/src/OutPerActionComplete/OutCreateComplete/sns-in-sqs/template.ejs +47 -0
  11. package/src/TemplateManager/src/OutPerActionComplete/OutCreateComplete/sns-out/data.js +62 -0
  12. package/src/TemplateManager/src/OutPerActionComplete/OutCreateComplete/sns-out/template.ejs +10 -0
  13. package/src/TemplateManager/src/PerActionEndpoint/FunctionYaml/HdrApi/data.js +2 -3
  14. package/src/TemplateManager/src/PerActionEndpoint/FunctionYaml/HdrInv/data.js +4 -2
  15. package/src/TemplateManager/src/PerActionEndpoint/Handler/HdrApi/data.js +1 -2
  16. package/src/TemplateManager/src/PerActionEndpoint/Handler/HdrInv/data.js +3 -3
  17. package/src/TemplateManager/src/PerActionEndpoint/MainFunction/Create/template.ejs +171 -177
  18. package/src/TemplateManager/src/ProcessLogical/mainFunction/template.ejs +9 -1
  19. package/src/TemplateManager/src/externalService/LambdaRole/data.js +3 -6
  20. package/src/TemplateManager/src/libs/Consts.js +1 -1
@@ -0,0 +1,62 @@
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 fs = require('fs');
21
+
22
+ const { ACTIONS, HANDLER } = require('@izara_project/izara-core-library-service-schemas/src/Consts')
23
+
24
+ const { firstLetterLowerCase: lowerCase, firstLetterUpperCase: upperCase, firstLetterUpperCase } = require("../../../../../MainLibs/src/Utils")
25
+ const { DEFAULT_HANDLER_PER_ACTION, SOURCE_PATH, SAVE_FILE_NAME, FUNCTION_NAME } = require("../../../libs/Consts");
26
+
27
+ const templatePath = path.join(__dirname, "../../../ResourceYaml/sns-out/template.ejs")
28
+ // /ResourceYaml/sns-out/template.ejs
29
+ // /OutPerActionComplete/OutUpdateComplete/sns-out/data.js
30
+ /**
31
+ * create data for dynamoDbYaml tempalte from objectSchema
32
+ * return array of dynamoDb data
33
+ * because one objectSchema can create multiple dynamoDb table
34
+ *
35
+ * @param {Object} _izContext
36
+ * @param {String} saveFilePath
37
+ * @returns {Object[]} - data of multiple dynamoDb template
38
+ */
39
+
40
+ function data(_izContext, srcPath) {
41
+ const createSourceParams = createParamsForCreateSource(_izContext, srcPath)
42
+ return [createSourceParams]
43
+ }
44
+
45
+ function createParamsForCreateSource(_izContext, srcPath) {
46
+ let queueName = FUNCTION_NAME.createObjectComplete
47
+ return {
48
+ templatePath: templatePath,
49
+ templateData: {
50
+ queueName: upperCase(queueName)
51
+ },
52
+ setting: {
53
+ initialData: 'Resources:\n',
54
+ savePath: path.join(srcPath, SOURCE_PATH.resourceYaml),
55
+ saveFileName: SAVE_FILE_NAME.snsOutYaml,
56
+ fileExtension: '.yml',
57
+ isAppend: true
58
+ }
59
+ }
60
+ }
61
+
62
+ module.exports = data
@@ -0,0 +1,10 @@
1
+ ##--------- [Create Topic Out]
2
+ Out<%- firstLetterUpperCase(queueName) %>:
3
+ Type: AWS::SNS::Topic
4
+ Properties:
5
+ DisplayName: "SNS Message out"
6
+ TopicName: ${self:custom.iz_resourcePrefix}Out<%- firstLetterUpperCase(queueName) %>
7
+
8
+ <%_ function firstLetterUpperCase(text) {
9
+ return text.charAt(0).toUpperCase() + text.slice(1)
10
+ } _%>
@@ -89,7 +89,6 @@ function data(_izContext, objectSchema, srcPath) {
89
89
 
90
90
  function createParamForCreateSource(objectSchema, action, srcPath) {
91
91
  let objectType = objectSchema.objectType;
92
- let actionHandler = action;
93
92
  let functionName = objectType + upperCase(actionHandler);
94
93
  let additionalResourcePermission = defaultIamRolePerAction();
95
94
  let tableForGetItem = [];
@@ -146,7 +145,7 @@ function createParamForCreateSource(objectSchema, action, srcPath) {
146
145
  createIamRole({
147
146
  [RESOURCE_CLASSES.sns]: [SNS_RESOURCE.publish]
148
147
  },
149
- resourceNames(RESOURCE_CLASSES.sns, "Out", upperCase(FUNCTION_NAME.updateNodeComplete)))
148
+ resourceNames(RESOURCE_CLASSES.sns, "Out" + upperCase(FUNCTION_NAME.updateNodeComplete)))
150
149
  )
151
150
  }
152
151
 
@@ -159,7 +158,7 @@ function createParamForCreateSource(objectSchema, action, srcPath) {
159
158
  additionalResourcePermission,
160
159
  event: event,
161
160
  objectType: objectType,
162
- action: actionHandler
161
+ action: action
163
162
  },
164
163
  setting: {
165
164
  savePath: path.join(srcPath, SOURCE_PATH.appYaml),
@@ -156,7 +156,9 @@ function createParamForCreateSource(objectSchema, action, srcPath) {
156
156
  additionalResourcePermission.push(
157
157
  createIamRole(
158
158
  {
159
- [RESOURCE_CLASSES.dynamoDbTable]: [DYNAMO_RESOURCE.putItem]
159
+ [RESOURCE_CLASSES.dynamoDbTable]: [DYNAMO_RESOURCE.putItem,
160
+ DYNAMO_RESOURCE.deleteItem, DYNAMO_RESOURCE.query
161
+ ]
160
162
  },
161
163
  [
162
164
  resourceNames(RESOURCE_CLASSES.dynamoDbTable, "AwaitingMultipleSteps"),
@@ -170,7 +172,7 @@ function createParamForCreateSource(objectSchema, action, srcPath) {
170
172
  [RESOURCE_CLASSES.sns]: [SNS_RESOURCE.publish]
171
173
  },
172
174
  [
173
- resourceNames(RESOURCE_CLASSES.sns, "Out" + upperCase(FUNCTION_NAME.createNodeComplete))
175
+ resourceNames(RESOURCE_CLASSES.sns, "Out" + upperCase(FUNCTION_NAME.createObjectComplete))
174
176
  ]
175
177
  )
176
178
  )
@@ -61,7 +61,6 @@ function data(_izContext, objectSchema, srcPath) {
61
61
 
62
62
  function createParamForCreateSource(objectSchema, action, srcPath) {
63
63
  let objectType = objectSchema.objectType;
64
- let actionHandler = action;
65
64
  let functionName = objectType + firstLetterUpperCase(action);
66
65
  const handler = HANDLER.hdrApi
67
66
  return {
@@ -69,7 +68,7 @@ function createParamForCreateSource(objectSchema, action, srcPath) {
69
68
  templateData: {
70
69
  functionName: functionName,
71
70
  objectType: objectType,
72
- actionHandler: actionHandler,
71
+ action: action,
73
72
  isCreateMainFunction: checkOverWriteGenerateMainFunction(objectSchema, action)
74
73
  },
75
74
  setting: {
@@ -57,15 +57,15 @@ function data(_izContext, objectSchema, srcPath) {
57
57
  } else {
58
58
  // if not have overWriteHander of action will use default handler
59
59
  const defaultHandler = DEFAULT_HANDLER_PER_ACTION[action]
60
- if (action = ACTIONS.get) {
60
+ if (action == ACTIONS.get) {
61
61
  if (defaultHandler.includes(HANDLER.hdrInv)) {
62
62
  // create template data and object for create source
63
63
  const createHandlerGet = createParamForCreateHandlerGet(objectSchema, action, HANDLER.hdrInv, srcPath)
64
64
  createHandlerGet && createSourceArray.push(createHandlerGet)
65
65
  }
66
- } else if (action = ACTIONS.update) {
66
+ } else if (action == ACTIONS.update) {
67
67
  const createHandlerUpdate = createParamForCreateHandlerUpdate(objectSchema, action, HANDLER.hdrInv, srcPath)
68
- createHandlerGet && createSourceArray.push(createHandlerUpdate);
68
+ createHandlerUpdate && createSourceArray.push(createHandlerUpdate);
69
69
  }
70
70
  }
71
71
  }
@@ -56,7 +56,8 @@ const PREFIX = {
56
56
  }
57
57
  //-----------------------------------------------------------------------------------------------------------
58
58
 
59
- const { createDataDetailsLib } = require('@izara_project/izara-market-library-service-schemas/src/GenerateCodeLibs/src/GenerateCodeLibs')
59
+ const { createCreateDataDetailsV2 } = require('@izara_project/izara-market-library-service-schemas/src/GenerateCodeLibs/src/GenerateCodeLibs')
60
+ const { createLinkTypeId } = require('@izara_project/izara-core-library-service-schemas/src/Utils');
60
61
 
61
62
  /**
62
63
  - all storageType( DB and Graph) use objInstance({identifiers,fields})
@@ -103,24 +104,158 @@ module.exports.<%- functionName %>Main = async (
103
104
  serviceTag: SERVICE_TAG
104
105
  }
105
106
 
106
- let objectSchema = await getObjectSchema.getObjSchemaS3WithHierarchy(
107
+ let objectSchema = await getObjectSchema.getObjSchemaS3WithCache(
107
108
  _izContext,
108
- {
109
- objectType: OBJECT_TYPE,
110
- serviceTag: SERVICE_TAG
111
- },
109
+ MAIN_OBJTYPE
112
110
  );
113
- _izContext.logger.debug("objectSchema:", objectSchema)
111
+ _izContext.logger.debug("objectSchema", objectSchema);
114
112
 
115
113
  let objectSchemas = uploadUseCase.generateObjectSchemaForGraphHandler(
116
114
  _izContext,
117
115
  objectSchema
118
116
  );
117
+ _izContext.logger.debug("objectSchemas", objectSchemas);
119
118
 
120
119
  let createDataDetails = await createCreateDataDetailsV2(_izContext, objectSchemas);
121
120
  _izContext.logger.debug("createDataDetails is =", createDataDetails);
122
121
 
123
- let objInstance = {
122
+ let errorsFound = [];
123
+
124
+ //validate linkType
125
+ if ((requestParams.hasOwnProperty("relationships")) && (requestParams.relationship.length > 0)) {
126
+
127
+ for (let relationshipProperties of requestParams.relationship) {
128
+ _izContext.logger.debug("relType", relationshipProperties.relType)
129
+ let getObjectRelationship = await getObjectSchema.getRelationshipSchemaWithCache(
130
+ _izContext,
131
+ relationshipProperties.relType
132
+ )
133
+ _izContext.logger.debug("getObjectRelationship", getObjectRelationship)
134
+
135
+ for (const relationshipLink of Object.values(getObjectRelationship.links)) {
136
+ if (relationshipLink.from.linkType === "many" && relationshipLink.to.linkType === "many") {
137
+ if (relationshipLink.from.requiredOnCreate === true || relationshipLink.to.requiredOnCreate === true) {
138
+ errorsFound.push("error many to many linkType can't have requireOnCreate === true")
139
+ }
140
+ }
141
+ }
142
+ }
143
+ }
144
+
145
+ // validate relationship link
146
+ let requiredOnCreateLinks = await getObjectSchema.getRequiredOnCreateLinksGraphHandlerWithCache(_izContext, MAIN_OBJTYPE);
147
+ _izContext.logger.debug("requiredOnCreateLinks", requiredOnCreateLinks);
148
+
149
+ let filterRequireOnCreateRels = {};
150
+
151
+ for (const [relationshipTag, relationshipProperties] of Object.entries(requiredOnCreateLinks)) {
152
+ let filterRequiredLinks = [];
153
+
154
+ for (const link of relationshipProperties.links) {
155
+ _izContext.logger.debug("linkObjectRelationship", link)
156
+ const serviceTags = await Promise.all(
157
+ link.storageResourceTags.map(async (storageTag) => {
158
+ let storageResource = relationshipProperties.storageResources[storageTag];
159
+ if (storageResource.storageType === consts.STORAGE_TYPES.graph) {
160
+ return await getGraphServiceTagWithCache(_izContext, storageResource.graphServerTag)
161
+ }
162
+ })
163
+ )
164
+ _izContext.logger.debug('serviceTags: ', serviceTags);
165
+
166
+ if (serviceTags.includes("GraphHandler")) {
167
+ filterRequiredLinks.push(link)
168
+ }
169
+ }
170
+
171
+ if (filterRequiredLinks.length) {
172
+ Object.assign(filterRequireOnCreateRels,
173
+ {
174
+ [relationshipTag]: {
175
+ ...relationshipProperties,
176
+ links: filterRequiredLinks
177
+ }
178
+ })
179
+ }
180
+ }
181
+ _izContext.logger.debug("filterRequireOnCreateRels", filterRequireOnCreateRels)
182
+
183
+ if (Object.keys(filterRequireOnCreateRels).length) {
184
+ if (!requestParams.relationship.length) {
185
+ for (const relTag in filterRequireOnCreateRels) {
186
+ errorsFound.push(`missing required relationship of relType: serviceTag: ${filterRequireOnCreateRels[relTag].relationshipServiceTag}, relationshipTag: ${relTag} when create`);
187
+ }
188
+ }
189
+
190
+ let requiredOnCreateLinks = {};
191
+ let createLinkTypeIds = [];
192
+
193
+ for (const [relTag, relationshipProperties] of Object.entries(filterRequireOnCreateRels)) {
194
+ _izContext.logger.debug("relationshipProperties", relationshipProperties);
195
+
196
+ for (const link of relationshipProperties.links) {
197
+ const requiredOnCreateLinkTypeId = createLinkTypeId(
198
+ _izContext,
199
+ [link.from.objType, link.to.objType],
200
+ {
201
+ relationshipTag: relTag,
202
+ serviceTag: relationshipProperties.relationshipServiceTag
203
+ }
204
+ )
205
+
206
+ Object.assign(requiredOnCreateLinks,
207
+ {
208
+ [requiredOnCreateLinkTypeId]: {
209
+ relType: {
210
+ relationshipTag: relTag,
211
+ serviceTag: relationshipProperties.relationshipServiceTag
212
+ },
213
+ link: link
214
+ }
215
+ })
216
+ _izContext.logger.debug("requiredOnCreateLinks", requiredOnCreateLinks)
217
+ }
218
+ }
219
+
220
+ for (const createRelationship of requestParams.relationship) {
221
+ const onCreateLinkTypeId = createLinkTypeId(
222
+ _izContext,
223
+ [MAIN_OBJTYPE, createRelationship.targetObjType],
224
+ createRelationship.relType
225
+ )
226
+
227
+ if (!requiredOnCreateLinks.hasOwnProperty(onCreateLinkTypeId)) {
228
+ errorsFound.push(`relType:${JSON.stringify(createRelationship.relType)} are not relationshipSchema for this objType`)
229
+ continue;
230
+ } else {
231
+ createLinkTypeIds.push(onCreateLinkTypeId)
232
+ }
233
+ // validate missing relType that should create
234
+ const remainRequiredOnCreateLinkTypeIds = Object.keys(requiredOnCreateLinks)
235
+ .filter(requiredOnCreateLinkTypeId => !createLinkTypeIds.includes(requiredOnCreateLinkTypeId));
236
+
237
+ if (remainRequiredOnCreateLinkTypeIds.length) {
238
+ for (const remainRequiredOnCreateLinkTypeId of remainRequiredOnCreateLinkTypeIds) {
239
+ const missingLink = {
240
+ from: requiredOnCreateLinks[remainRequiredOnCreateLinkTypeId].link.from,
241
+ to: requiredOnCreateLinks[remainRequiredOnCreateLinkTypeId].link.to,
242
+ };
243
+ errorsFound.push(`Missing link:${JSON.stringify(missingLink)} when create`);
244
+ }
245
+ }
246
+
247
+ _izContext.logger.debug("requiredOnCreateLinks: ", requiredOnCreateLinks);
248
+ _izContext.logger.debug("onCreateLinkTypeIds: ", createLinkTypeIds);
249
+
250
+ }
251
+ } else {
252
+
253
+ if (requestParams.relationships.length) {
254
+ errorsFound.push(`objType:${JSON.stringify(objType)} not need relationships when create`);
255
+ }
256
+ }
257
+
258
+ let objInstanceFull = {
124
259
  identifiers: {},
125
260
  fields: {}
126
261
  };
@@ -129,8 +264,9 @@ module.exports.<%- functionName %>Main = async (
129
264
  let listOfOptionalOnCreate = [];
130
265
 
131
266
  let allAwaitingStepsId = [];
132
- let errorsFound = [];
133
267
 
268
+
269
+ // validate single identifiers
134
270
  if (objectSchemas.identifiers.length === 1 && !identifier.hasOwnProperty("fieldNames")) {
135
271
 
136
272
  const identifier = objectSchemas.identifiers[0];
@@ -151,10 +287,11 @@ module.exports.<%- functionName %>Main = async (
151
287
  callingFlowConfig: callingFlowConfig
152
288
  })
153
289
  });
154
-
290
+ _izContext.logger.debug("Assign requestParams", requestParams)
155
291
  }
156
292
 
157
- } else if ((objectSchemas.fieldNames[identifier.fieldName].randomOnCreate == false)) {
293
+ } else if ((objectSchemas.fieldNames[identifier.fieldName].randomOnCreate == false) ||
294
+ (objectSchemas.fieldNames[identifier.fieldName].randomOnCreate == null)) {
158
295
 
159
296
  if ((objectSchemas.fieldNames[identifier.fieldName].requiredOnCreate == true) &&
160
297
  ((objectSchemas.fieldNames[identifier.fieldName].optionalOnCreate == false) || objectSchemas.fieldNames[identifier.fieldName].optionalOnCreate == true) &&
@@ -202,9 +339,12 @@ module.exports.<%- functionName %>Main = async (
202
339
  };
203
340
  };
204
341
 
342
+
205
343
  }; // end iteration of fieldNames
206
344
 
207
- for (let fieldName of Object.keys(requestParams.fieldNames)) {
345
+ _izContext.logger.debug("listOfRequriedOnCreate", listOfRequriedOnCreate);
346
+ _izContext.logger.debug("listOfOptionalOnCreate", listOfOptionalOnCreate);
347
+ for (let fieldName of Object.keys(requestParams.objInstanceFull.fieldNames)) {
208
348
 
209
349
  if (!listOfRequriedOnCreate.includes(fieldName)) {
210
350
  if (!listOfOptionalOnCreate.includes(fieldName)) {
@@ -237,39 +377,37 @@ module.exports.<%- functionName %>Main = async (
237
377
  }; // end loop
238
378
 
239
379
  let listOfObjectForCreates = [];
240
- let serviceName;
241
- let createDataDetail;
242
380
  if (errorsFound.length == 0) {
243
381
 
244
- for ([serviceName, createDataDetail] of Object.entries(createDataDetails)) {
382
+ for (let [serviceName, createDataDetail] of Object.entries(createDataDetails)) {
245
383
 
246
- for (let fieldNames of Object.keys(requestParams.fieldNames)) {
384
+ for (let fieldNames of Object.keys(requestParams.objInstanceFull.fieldNames)) {
247
385
 
248
386
  if (createDataDetail.fieldNames.includes(fieldNames) && listOfRequriedOnCreate.includes(fieldNames)) {
249
387
  _izContext.logger.debug("fieldNames match in detail is:", fieldNames);
250
388
 
251
- if (objInstance.hasOwnProperty("fields")) {
252
- Object.assign(objInstance.fields, {
253
- [fieldNames]: requestParams.fieldNames[fieldNames]
389
+ if (objInstanceFull.hasOwnProperty("fields")) {
390
+ Object.assign(objInstanceFull.fields, {
391
+ [fieldNames]: requestParams.objInstanceFull.fieldNames[fieldNames]
254
392
  })
255
393
  } else {
256
- Object.assign(objInstance, {
394
+ Object.assign(objInstanceFull, {
257
395
  fields: {
258
- [fieldNames]: requestParams.fieldNames[fieldNames]
396
+ [fieldNames]: requestParams.objInstanceFull.fieldNames[fieldNames]
259
397
  }
260
398
  })
261
399
  };
262
400
  };
263
401
  };
264
-
402
+ _izContext.logger.debug("objInstanceFull", objInstanceFull)
265
403
  if (createDataDetail.storageType == consts.STORAGE_TYPES.dynamoDB) {
266
- _izContext.logger.debug("::::::DynamoDB::::::", { serviceName, objInstance });
404
+ _izContext.logger.debug("::::::DynamoDB::::::", { serviceName, objInstanceFull });
267
405
 
268
406
  let identifiersForCreateData = await dynamoDbIdentifiersByStorageResource(
269
407
  _izContext,
270
408
  objectSchema,
271
409
  createDataDetails,
272
- requestParams.fieldNames
410
+ requestParams.objInstanceFull.fieldNames
273
411
  )
274
412
  _izContext.logger.debug("identifiersForCreateData", identifiersForCreateData);
275
413
 
@@ -284,22 +422,22 @@ module.exports.<%- functionName %>Main = async (
284
422
 
285
423
 
286
424
  } else if (createDataDetail.storageType == consts.STORAGE_TYPES.graph) {
287
- _izContext.logger.debug("::::::Graphanler::::::", { serviceName, objInstance });
425
+ _izContext.logger.debug("::::::Graphanler::::::", { serviceName, objInstanceFull });
288
426
 
289
427
  // allStorageTagComplete = false;
290
428
  allAwaitingStepsId.push(asyncFlowSharedLib.createAwaitingStepId(
291
429
  (hash({
292
430
  objType: MAIN_OBJTYPE,
293
431
  graphServerTag: serviceName,
294
- identifiers: objInstance.identifiers
432
+ identifiers: objInstanceFull.identifiers
295
433
  })),
296
434
  PREFIX.CREATE_OBJECT_ASYNC
297
435
  ));
298
436
  listOfObjectForCreates.push({
299
437
  [serviceName]: {
300
- objInstance: {
301
- identifiers: objInstance.identifiers,
302
- fields: objInstance.fields
438
+ objInstanceFull: {
439
+ identifiers: objInstanceFull.identifiers,
440
+ fields: objInstanceFull.fields
303
441
  },
304
442
  allStorageTagComplete: false
305
443
  }
@@ -310,7 +448,7 @@ module.exports.<%- functionName %>Main = async (
310
448
  };
311
449
  _izContext.logger.debug("[1]listOfObjectForCreates:::", listOfObjectForCreates);
312
450
 
313
- delete objInstance.fields
451
+ delete objInstanceFull.fields
314
452
  };
315
453
  };
316
454
 
@@ -319,7 +457,7 @@ module.exports.<%- functionName %>Main = async (
319
457
  await asyncFlowSharedLib.createAwaitingMultipleSteps(
320
458
  _izContext,
321
459
  allAwaitingStepsId,
322
- asyncFlowSharedLib.createPendingStepId((hash({ objType: MAIN_OBJTYPE, identifiers: objInstance.identifiers })), PREFIX.CREATE_OBJECT_ASYNC_COMPLETE)
460
+ asyncFlowSharedLib.createPendingStepId((hash({ objType: MAIN_OBJTYPE, identifiers: objInstanceFull.identifiers })), PREFIX.CREATE_OBJECT_ASYNC_COMPLETE)
323
461
  );
324
462
  //............................................................................................................
325
463
 
@@ -336,152 +474,8 @@ module.exports.<%- functionName %>Main = async (
336
474
 
337
475
  messageObject = {
338
476
  objType: MAIN_OBJTYPE,
339
- objInstance: objecForCreate.objInstance,
477
+ objInstanceFull: objecForCreate.objInstanceFull,
340
478
  };
341
-
342
- /*
343
- seagame: should getRequiredOnCreateLinksGraphHandler before match with requestParams.relationships
344
- this condition will miss validation when objType have requiredOnCreateLink but not send relationships from requestParams
345
- */
346
-
347
- if (requestParams.hasOwnProperty("relationships") && requestParams.relationships.length > 0) {
348
- _izContext.logger.debug("SHOW RELATIONSHIP:", requestParams.relationships);
349
-
350
- // validate relationship only.
351
- let getRelationhsipSchemas = await getObjectSchema.getRequiredOnCreateLinksGraphHandler(
352
- _izContext,
353
- {
354
- objectType: OBJECT_TYPE,
355
- serviceTag: SERVICE_TAG
356
- }
357
- );
358
-
359
- _izContext.logger.debug("getRelationhsipSchemas is:::", getRelationhsipSchemas);
360
-
361
- if (Object.keys(getRelationhsipSchemas).length !== requestParams.relationships.length) {
362
- errorsFound.push("[invalid]relationships missmatch requiredOnCreateLink form relationshipschemas");
363
- } else {
364
-
365
- for (let eachRelationships of requestParams.relationships) {
366
- _izContext.logger.debug("eachRelationships is:", eachRelationships);
367
-
368
- // validate porperty in relatoinships.
369
- if (!eachRelationships.hasOwnProperty("relType") || Object.keys(eachRelationships.relType).length == 0) {
370
- errorsFound.push("[invalid relationsips] property relType in relationsips");
371
- };
372
- if (!eachRelationships.hasOwnProperty("targetObjType") || Object.keys(eachRelationships.targetObjType).length == 0) {
373
- errorsFound.push("[invalid relationsips] property targetObjType in relationsips");
374
- };
375
- if (!eachRelationships.hasOwnProperty("targetIdentifiers") || Object.keys(eachRelationships.targetIdentifiers).length == 0) {
376
- errorsFound.push("[invalid relationsips] property targetIdentifiers in relationsips");
377
- };
378
-
379
- let relationshipTag = eachRelationships.relType.relationshipTag
380
- let eachRelationhsipSchemas = getRelationhsipSchemas[eachRelationships.relType.relationshipTag]
381
- let targetObjType = eachRelationships.targetObjType
382
-
383
- _izContext.logger.debug("each Relationhsip is:::::", {
384
- relationshipTag,
385
- eachRelationhsipSchemas: eachRelationhsipSchemas,
386
- targetObjType
387
- });
388
-
389
- if (!eachRelationhsipSchemas) {
390
- errorsFound.push("misMatch relationhsipSchemas requriOnCreate");
391
- };
392
-
393
- if (errorsFound.length > 0) {
394
- break
395
- };
396
-
397
- let objTypeRequiredOnCreate = null;
398
- for (let link of eachRelationhsipSchemas.links) {
399
- /*
400
- seagame: one relationshipSchema probably have 2 or more links that contain mainObjType but have difference targetObjType
401
- */
402
-
403
- let objectSides = {
404
- from: MAIN_OBJTYPE,
405
- to: targetObjType
406
- };
407
-
408
- if (link.from.objType.serviceTag == targetObjType.serviceTag &&
409
- link.from.objType.objectType == targetObjType.objectType) {
410
- objectSides = {
411
- from: targetObjType,
412
- to: MAIN_OBJTYPE
413
- };
414
- };
415
- _izContext.logger.debug("check side:", objectSides);
416
-
417
- // test both sides of link
418
- // let otherLinkConfigKey = "from";
419
- for (let linkKey of Object.keys(link)) {
420
- // _izContext.logger.debug("linkKey is:", linkKey);
421
- if (linkKey == "to" || linkKey == "from") {
422
- // set other side key
423
- let otherLinkConfigKey = "from";
424
- if (linkKey == "from") {
425
- otherLinkConfigKey = "to";
426
- }
427
-
428
- // case ONE-to-ONE
429
- if (link[linkKey].linkType == "one" &&
430
- link[otherLinkConfigKey].linkType == "one") {
431
- _izContext.logger.debug("case ONE-to-ONE");
432
- if (link[linkKey].requiredOnCreate == true) {
433
-
434
- objTypeRequiredOnCreate = objectSides[linkKey];
435
- };
436
- };
437
-
438
- // case ONE-to-MANY
439
- if (link[linkKey].linkType == "many" &&
440
- link[otherLinkConfigKey].linkType == "one") {
441
- _izContext.logger.debug("case ONE-to-MANY");
442
-
443
- if (link[linkKey].requiredOnCreate == true) {
444
-
445
- objTypeRequiredOnCreate = objectSides[linkKey];
446
- };
447
- };
448
-
449
- if ((objTypeRequiredOnCreate !== null && link[otherLinkConfigKey].objType !== null)) {
450
- /*
451
- seagame: one relationshipSchema probably have 2 or more links that contain mainObjType but have difference targetObjType
452
- if check other side with targetObjType will cause errors
453
- */
454
- if (
455
- ((objTypeRequiredOnCreate.objectType == MAIN_OBJTYPE.objectType) && (objTypeRequiredOnCreate.serviceTag == MAIN_OBJTYPE.serviceTag)) &&
456
- ((link[otherLinkConfigKey].objType.objectType == targetObjType.objectType) && (link[otherLinkConfigKey].objType.serviceTag == targetObjType.serviceTag))) {
457
-
458
- // seagame:
459
- // this line will re assign every time when validate requestParams.relationships
460
- // should finished validate all requestParams.relationships before assign to messageObject
461
- Object.assign(messageObject, { relationships: requestParams.relationships });
462
- _izContext.logger.debug("messageObject case relationships", messageObject)
463
-
464
- } else {
465
- errorsFound.push("[Invalid]main objType is not requriOnCreate")
466
- };
467
-
468
- }
469
-
470
- if (errorsFound.length > 0) {
471
- break
472
- };
473
- };
474
-
475
-
476
- }; // end check linkKey.
477
- }; // end links
478
- }; // end loop requestParams.relationships
479
- }; // end eachRelationships
480
-
481
- if (errorsFound.length > 0) {
482
- break
483
- };
484
- }; // case relationships
485
479
  };
486
480
 
487
481
  if (errorsFound.length > 0) {
@@ -531,7 +525,7 @@ module.exports.<%- functionName %>Main = async (
531
525
  _izContext,
532
526
  asyncFlowSharedLib.createPendingStepId((hash({
533
527
  objType: MAIN_OBJTYPE,
534
- identifiers: objInstance.identifiers
528
+ identifiers: objInstanceFull.identifiers
535
529
  })), PREFIX.CREATE_OBJECT_ASYNC_COMPLETE)); // pendingStepId
536
530
 
537
531
  // send message to OutCreateObjectComplete.
@@ -32,6 +32,9 @@ const { getUsedFieldNamesOfIdentifiers } = serviceSchemas.utils;
32
32
 
33
33
  const sns = require('@izara_project/izara-core-library-external-request').sns;
34
34
 
35
+ //(<additionalModule>)
36
+ //(</additionalModule>)
37
+
35
38
  /**
36
39
  * performs the logical operation/filter/search in the element, saves into LogicalResultsData table
37
40
  * @param {Object} _izContext
@@ -62,13 +65,18 @@ module.exports.processLogical = async (
62
65
  callingFlow: callingFlow
63
66
  });
64
67
 
68
+ let removeAttributes = ["paginateProcessLogicalUniqueRequestId"];
69
+
70
+ //(<removeAttributes>)
71
+ //(</removeAttributes>)
72
+
65
73
  // Check/Create logicalResultsMain
66
74
  let [logicalResultsMainStatus, logicalResultId, logicalResultMain] = await logicalResultsSharedLib.checkLogicalMainStatus(
67
75
  _izContext,
68
76
  element, // for create logicalResultId
69
77
  objType,
70
78
  callingFlow,
71
- ["paginateProcessLogicalUniqueRequestId"]
79
+ removeAttributes
72
80
  );
73
81
  _izContext.logger.debug("After check logicalMainStatus: ", {
74
82
  logicalResultsMainStatus: logicalResultsMainStatus,