@izara_project/izara-market-library-service-schemas 1.0.10 → 1.0.11

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@izara_project/izara-market-library-service-schemas",
3
- "version": "1.0.10",
3
+ "version": "1.0.11",
4
4
  "description": "Schemas for Izara Market project",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -68,31 +68,31 @@ module.exports.createObjectComplete = async (
68
68
  };
69
69
  // validate.
70
70
  if (!returnValue.hasOwnProperty("queryResult")) {
71
- errorFounds.push("message is not have property queryResult, should be not happen");
71
+ errorsFound.push("message is not have property queryResult, should be not happen");
72
72
  };
73
73
  if (!returnValue.hasOwnProperty("objType")) {
74
- errorFounds.push("message is not have property objType, should be not happen");
74
+ errorsFound.push("message is not have property objType, should be not happen");
75
75
  };
76
76
  if (!returnValue.hasOwnProperty("objInstanceFull")) {
77
- errorFounds.push("message is not have property objInstance, should be not objInstance");
77
+ errorsFound.push("message is not have property objInstance, should be not objInstance");
78
78
  };
79
79
 
80
80
  if (status == "error" && errorsFound.length > 0) {
81
- errorFounds.push(errorsFound);
81
+ errorsFound.push(errorsFound);
82
82
  } else if (status == "error" && errorsFound.length == 0) {
83
- errorFounds.push("[invalid]statur is error not have errorfound form graphService");
83
+ errorsFound.push("[invalid]statur is error not have errorfound form graphService");
84
84
 
85
85
  };
86
86
  if (status === "complete" && errorsFound.length > 0) {
87
- errorFounds.push("[Invalid] status is commplete should be not have errorsFound");
87
+ errorsFound.push("[Invalid] status is commplete should be not have errorsFound");
88
88
  };
89
89
  if (graphServiceTag == null) {
90
- errorFounds.push("[Invalid] graphServerTag is not empty string");
90
+ errorsFound.push("[Invalid] graphServerTag is not empty string");
91
91
  };
92
92
 
93
93
  if (errorsFound.length > 0) {
94
94
  _izContext.logger.debug("Have error form grapService:", errorsFound);
95
- errorFounds = errorFounds.concat(errorsFound);
95
+ errorsFound = errorsFound.concat(errorsFound);
96
96
  };
97
97
 
98
98
  let awaitingStepId = await asyncFlowSharedLib.createAwaitingStepId(
@@ -159,8 +159,8 @@ module.exports.createObjectComplete = async (
159
159
  await sns.publishAsync(_izContext, sendMessageOutCreateObjectComplete);
160
160
 
161
161
  return {
162
- objType: returnValue.objType,
163
- objInstanceFull: returnValue.objInstanceFull,
162
+ returnValue: returnValue,
163
+ status: status,
164
164
  errorsFound: errorsFound
165
165
  }
166
166
 
@@ -35,7 +35,7 @@ const {
35
35
  //validate event params in middleware before into main function
36
36
  validateSchemaMiddleware(
37
37
  middleware,
38
- "<%- firstLetterUpperCase(objectType) %>",
38
+ "<%- (objectType) %>",
39
39
  "<%- action %>"
40
40
  //(<validateSchemaSetting>
41
41
  //</validateSchemaSetting>)
@@ -40,7 +40,7 @@ const {
40
40
  //validate event params in middleware before into function
41
41
  validateSchemaMiddleware(
42
42
  middleware,
43
- "<%- firstLetterUpperCase(objectType) %>", // objectType
43
+ "<%- (objectType) %>", // objectType
44
44
  "<%- action %>", // action
45
45
  //(<validateSchemaSetting>)
46
46
  //(</validateSchemaSetting>)
@@ -223,7 +223,8 @@ module.exports.<%- functionName %>Main = async (
223
223
  _izContext,
224
224
  MAIN_OBJTYPE,
225
225
  requireLink.other.objType,
226
- requireLink.relType
226
+ requireLink.relType,
227
+ requireLink.base.direction
227
228
  );
228
229
 
229
230
  Object.assign(requiredOnCreateLinks, {
@@ -236,7 +237,8 @@ module.exports.<%- functionName %>Main = async (
236
237
  _izContext,
237
238
  MAIN_OBJTYPE,
238
239
  createRelationship.targetObjType,
239
- createRelationship.relType
240
+ createRelationship.relType,
241
+ createRelationship.relationshipDirection
240
242
  );
241
243
 
242
244
  if (!requiredOnCreateLinks.hasOwnProperty(onCreateLinkTypeId)) {
@@ -561,7 +563,7 @@ module.exports.<%- functionName %>Main = async (
561
563
  return {
562
564
  objType: MAIN_OBJTYPE,
563
565
  fieldNames: requestParams.fieldNames,
564
- relationship: requestParams.relationships,
566
+ relationships: requestParams.relationships,
565
567
  status: "complete",
566
568
  }
567
569
  }
@@ -280,7 +280,7 @@ module.exports.<%- functionName %> = async (
280
280
 
281
281
 
282
282
  // before create awaitingStepId per graph storageResource
283
- const linkTypeId = createLinkTypeId(_izContext, firstObject.objType, secondObject.objType, relType);
283
+ const linkTypeId = createLinkTypeId(_izContext, firstObject.objType, secondObject.objType, relType, relationshipDirection);
284
284
 
285
285
  let usedGraphServiceTag = []; // collect used graph serviceTag, use to check duplicate graph serviceTag across graph serverTag
286
286
  let targetGraphStorageResources = []; // collect used graph storageResources, filtered duplicate graphServiceTag from graphServerTag out
@@ -24,11 +24,9 @@ const lambdaSharedLib = izaraShared.lambdaSharedLib;
24
24
  const graphSharedLib = izaraShared.graphSharedLib;
25
25
 
26
26
 
27
-
28
27
  const translateIdsSharedLib = require('@izara_project/izara-translateids/src/TranslateIdsLib');
29
28
  const NoRetryError = require('@izara_project/izara-core-library-core/src/NoRetryError');
30
29
  const lambda = require('@izara_project/izara-core-library-external-request/src/resources/Lambda');
31
- const TranslateIdsLibs = require('@izara_project/izara-market-library-service-schemas/src/GenerateCodeLibs/src/TranslateIdsLibs')
32
30
  const serviceSchemas = require("@izara_project/izara-core-library-service-schemas");
33
31
  const identifiersObject = require('@izara_project/izara-core-library-service-schemas/src/IdentifiersObject');
34
32
  const getObjectSchema = require("@izara_project/izara-core-library-service-schemas/src/GetObjectSchema")
@@ -45,7 +43,6 @@ const { firstLetterUpperCase: upperCase } = require('@izara_project/izara-market
45
43
  * @param {string} fromPartitionKeyFieldName - partition key field/attribute name
46
44
  * @param {string} fromDataFieldName - data field/attribute name
47
45
  * @param {object} toObjType - the type of object we are translating ids to
48
- * @param {string} toTypeId - the type of object we are translating ids to
49
46
  * @param {Object} [additionalData={}] - additional data to send back in completed message
50
47
  * @param {Object} [startKey={}] - first invoke will be empty
51
48
  * @param {Nummic} invocationCount
@@ -58,13 +55,12 @@ module.exports.processTranslateIds = async (
58
55
  _izContext,
59
56
  fromObjType,
60
57
  fromTypeId,
61
- identifiers, // identifiers
58
+ identifiers,
62
59
  fromTable,
63
60
  fromPartitionKeyId,
64
61
  fromPartitionKeyFieldName,
65
62
  fromDataFieldName,
66
63
  toObjType,
67
- toTypeId,
68
64
  relType,
69
65
  translateIdsCacheId,
70
66
  uniqueRequestId,
@@ -74,10 +70,6 @@ module.exports.processTranslateIds = async (
74
70
  passOnErrorsFound,
75
71
  callingFlow = "",
76
72
  ) => {
77
- // translateIds request to change from propertyIds to mediaLinkIds.
78
- // MediaLinkProperty: filter dataId is propertyIds
79
- // MediaLinkPropertyTranslation: filter dataId is propertyIds
80
- // translate 2 time , propertyIds from MediaLinkProperty and propertyIds from MediaLinkPropertyTranslation
81
73
  try {
82
74
  _izContext.logger.debug("=== Function:ProcessTranslateIds ===", {
83
75
  fromObjType: fromObjType,
@@ -88,7 +80,6 @@ module.exports.processTranslateIds = async (
88
80
  fromPartitionKeyFieldName: fromPartitionKeyFieldName,
89
81
  fromDataFieldName: fromDataFieldName,
90
82
  toObjType: toObjType,
91
- toTypeId: toTypeId,
92
83
  relType: relType,
93
84
  translateIdsCacheId: translateIdsCacheId,
94
85
  uniqueRequestId: uniqueRequestId,
@@ -100,31 +91,16 @@ module.exports.processTranslateIds = async (
100
91
  });
101
92
 
102
93
  let errorsFound = [];
103
- // Query resultDatas from table
104
- /*
105
- receive fromType , toType , relType check relationshipSchema return boolean
106
- just validate to check for error or use for do something further
107
- if false throw error if true continue translateIds+
108
- */
109
- // let validateObjTypeStatus = await validateFromTypeToToTypeWithRelType(_izContext, fromObjType, toObjType, relType
110
- let validateObjTypes = await TranslateIdsLibs.validateObjtypesAndRelType(_izContext, [fromObjType, toObjType], relType)
111
- if (validateObjTypes == null) {
112
- errorsFound = errorsFound.concat(`can't find ${fromObjType} and ${toObjType} in relationshipTag:${JSON.stringify(relType)}`)
113
- }
114
94
 
115
- /*
116
- check fromIdentifiers if have use it
117
- if not query data from table by using TranslateIdsGetResultIds
118
- */
119
95
  let resultDatas;
120
96
  let lastEvaluatedKeyResultDatas;
121
97
 
122
-
123
98
  // incase didn't send identifiers
124
99
  if (!identifiers) {
125
100
 
126
101
  let getFromObjectSchema = await getObjectSchema.getObjSchemaS3WithHierarchy(_izContext, fromObjType);
127
102
  _izContext.logger.debug("getFromObjectSchema", getFromObjectSchema);
103
+
128
104
  // create Full tableName
129
105
  let tableName = await dynamodbSharedLib.tableName(_izContext, fromTable, upperCase(getFromObjectSchema.complexFilterServiceTag));
130
106
  _izContext.logger.debug("tableName", tableName);
@@ -136,22 +112,12 @@ module.exports.processTranslateIds = async (
136
112
  startKey
137
113
  )
138
114
 
139
- // lastEvaluatedKeyResultDatas.LastEvaluatedKey
140
- /*
141
- if not have resultDatas it mean you cant query identifier from table and you didn't send identifier it will return error
142
- */
143
115
  _izContext.logger.debug("resultDatas query fromtable =>", resultDatas);
144
116
  if (!resultDatas && identifiers === undefined) {
145
117
  errorsFound.push(`Can not get resultDatas form Table${fromTable} and not have concatinateIdentifier to TranslateIds`)
146
118
  }
147
119
  }
148
120
 
149
- /*
150
- use from concatinateIdentifier to send in processOneRecord
151
- concatinateIdentifier type string
152
- check if in cache and if no save to TranslateIdsCacheFromIdDataTable, then move on to next resultData{fromDataId}
153
- */
154
-
155
121
  async function processOneRecord(
156
122
  _izContext,
157
123
  translateIdsCacheId,
@@ -32,6 +32,7 @@ const lambda = require('@izara_project/izara-core-library-external-request/src/r
32
32
  const serviceSchemas = require("@izara_project/izara-core-library-service-schemas");
33
33
  const identifiersObject = require('@izara_project/izara-core-library-service-schemas/src/IdentifiersObject');
34
34
  const getObjectSchema = require("@izara_project/izara-core-library-service-schemas/src/GetObjectSchema");
35
+ const TranslateIdsLibs = require('@izara_project/izara-market-library-service-schemas/src/GenerateCodeLibs/src/TranslateIdsLibs')
35
36
  const sqs = externalRequest.sqs
36
37
 
37
38
 
@@ -46,7 +47,6 @@ const sqs = externalRequest.sqs
46
47
  * @param {string} fromPartitionKeyFieldName - partition key field/attribute name
47
48
  * @param {string} fromDataFieldName - data field/attribute name
48
49
  * @param {object} toObjType - the type of object we are translating ids to
49
- * @param {string} toTypeId - the type of object we are translating ids to
50
50
  * @param {Object} [additionalData={}] - additional data to send back in completed message
51
51
  * @param {Object} [startKey={}] - first invoke will be empty
52
52
  * @param {Nummic} invocationCount
@@ -65,18 +65,10 @@ module.exports.translateIdsRequest = async (
65
65
  fromPartitionKeyFieldName,
66
66
  fromDataFieldName,
67
67
  toObjType,
68
- toTypeId,
69
68
  relType,
70
- // startKey ,
71
- // invocationCount,
72
- // passOnStatus,
73
- // passOnErrorsFound,
74
69
  callingFlow = "",
75
70
  ) => {
76
- // translateIds request to change from propertyIds to mediaLinkIds.
77
- // MediaLinkProperty: filter dataId is propertyIds
78
- // MediaLinkPropertyTranslation: filter dataId is propertyIds
79
- // translate 2 time , propertyIds from MediaLinkProperty and propertyIds from MediaLinkPropertyTranslation
71
+
80
72
  try {
81
73
  _izContext.logger.debug("=== Function:TranslateIdsRequest ===", {
82
74
  fromObjType: fromObjType,
@@ -93,12 +85,6 @@ module.exports.translateIdsRequest = async (
93
85
  callingFlow: callingFlow
94
86
  });
95
87
 
96
- /*
97
- receive params
98
- check main cache for all param that send in
99
- use concatinateIdentifier to check cache
100
- */
101
-
102
88
  //check cache per filterMain
103
89
  let [translateIdsCacheMainStatus, translateIdsCacheId, translateIdsCacheMain] = await translateIdsSharedLib.translateIdsCheckCacheMain(
104
90
  _izContext,
@@ -118,6 +104,11 @@ module.exports.translateIdsRequest = async (
118
104
  translateIdsCacheMain: translateIdsCacheMain
119
105
  });
120
106
 
107
+ let validateObjTypes = await TranslateIdsLibs.validateObjtypesAndRelType(_izContext, [fromObjType, toObjType], relType)
108
+ if (validateObjTypes == null) {
109
+ errorsFound = errorsFound.concat(`can't find ${fromObjType} and ${toObjType} in relationshipTag:${JSON.stringify(relType)}`)
110
+ }
111
+
121
112
  if (translateIdsCacheMainStatus !== "process") {
122
113
  return;
123
114
  };
@@ -132,7 +123,6 @@ module.exports.translateIdsRequest = async (
132
123
  fromPartitionKeyFieldName: fromPartitionKeyFieldName,
133
124
  fromDataFieldName: fromDataFieldName,
134
125
  toObjType: toObjType,
135
- toTypeId: toTypeId,
136
126
  relType: relType,
137
127
  invocationCount: 1,
138
128
  translateIdsCacheId: translateIdsCacheId,