@izara_project/izara-market-library-service-schemas 1.0.10 → 1.0.12
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 +2 -2
- package/src/GenerateCodeLibs/src/GenerateCodeLibs.js +164 -111
- package/src/TemplateManager/src/GenerateCode.js +6 -6
- package/src/TemplateManager/src/OutPerActionComplete/OutCreateComplete/mainFunction/template.ejs +10 -10
- package/src/TemplateManager/src/PerActionEndpoint/Handler/HdrApi/data.js +4 -4
- package/src/TemplateManager/src/PerActionEndpoint/Handler/HdrApi/template.ejs +1 -1
- package/src/TemplateManager/src/PerActionEndpoint/Handler/HdrInv/template.ejs +1 -1
- package/src/TemplateManager/src/PerActionEndpoint/MainFunction/Create/template.ejs +8 -6
- package/src/TemplateManager/src/PerActionEndpoint/MainFunction/Get/template.ejs +148 -139
- package/src/TemplateManager/src/RelationshipPerAction/CreateRelationship/createRelationship/mainFunction/template.ejs +1 -1
- package/src/TemplateManager/src/ResourceYaml/sns-in-sqs/snsAndSqsPerActiondata.js +1 -1
- package/src/TemplateManager/src/ResourceYaml/sns-out/data.js +1 -1
- package/src/TemplateManager/src/TranslateIdReq/ProcessingTranslateIds/mainFunction/template.ejs +2 -36
- package/src/TemplateManager/src/TranslateIdReq/TranslateIds/mainFunction/template.ejs +7 -17
- package/src/TemplateManager/src/PerActionEndpoint/MainFunction/Create/CreateObject_main.js +0 -760
|
@@ -16,120 +16,125 @@ Copyright (C) 2020 Sven Mason <http: //izara.io>
|
|
|
16
16
|
<http: //www.gnu.org/licenses />.
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
'use strict';
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
const {
|
|
22
22
|
getObjSchemaS3WithHierarchy,
|
|
23
|
-
|
|
23
|
+
} = require('@izara_project/izara-core-library-service-schemas/src/GetObjectSchema');
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
const {
|
|
26
26
|
getGraphServiceTagWithCache,
|
|
27
|
-
|
|
28
|
-
} = require('@izara_project/izara-core-library-service-schemas/src/ServiceConfig');
|
|
27
|
+
} = require('@izara_project/izara-core-library-service-schemas/src/ServiceConfig');
|
|
29
28
|
|
|
30
|
-
|
|
29
|
+
const consts = require('@izara_project/izara-core-library-service-schemas/src/Consts');
|
|
31
30
|
|
|
31
|
+
const {
|
|
32
|
+
objInstanceFromobjInstanceBase
|
|
33
|
+
} = require('@izara_project/izara-core-library-service-schemas/src/IdentifiersObject');
|
|
32
34
|
|
|
33
|
-
|
|
35
|
+
const {
|
|
34
36
|
dynamoDbIdentifiersByStorageResource,
|
|
35
|
-
collectGetData
|
|
36
|
-
|
|
37
|
+
collectGetData,
|
|
38
|
+
createGetDataDetails,
|
|
39
|
+
} = require('@izara_project/izara-market-library-service-schemas/src/GenerateCodeLibs/src/GenerateCodeLibs');
|
|
37
40
|
|
|
38
41
|
|
|
39
|
-
|
|
40
|
-
|
|
42
|
+
const dynamodbSharedLib = require('@izara_project/izara-shared/src/DynamodbSharedLib');
|
|
43
|
+
const graphSharedLib = require('@izara_project/izara-shared/src/GraphSharedLib');
|
|
41
44
|
|
|
45
|
+
const NoRetryError = require('@izara_project/izara-core-library-core/src/NoRetryError');
|
|
42
46
|
|
|
43
|
-
const NoRetryError = require('@izara_project/izara-core-library-core/src/NoRetryError');
|
|
44
|
-
const { createGetDataDetails } = require('@izara_project/izara-market-library-service-schemas/src/GenerateCodeLibs/src/GenerateCodeLibs')
|
|
45
47
|
|
|
46
48
|
|
|
47
49
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
50
|
+
/**
|
|
51
|
+
*
|
|
52
|
+
*
|
|
53
|
+
* description of function.
|
|
54
|
+
* @param {Object} _izContext
|
|
55
|
+
* @param {CorrelationIds} _izContext.correlationIds - property of _izContext
|
|
56
|
+
* @param {Logger} _izContext.logger - property of _izContext
|
|
57
|
+
* @param {Object} requestParams - request params
|
|
58
|
+
* @param {Object} requestParams.identifiers - identifiers for get data
|
|
59
|
+
* @param {Object} requestParams.additionalRequest - additionalRequest
|
|
60
|
+
*
|
|
61
|
+
*
|
|
62
|
+
* @returns {object} description of return value
|
|
63
|
+
*/
|
|
64
|
+
module.exports.<%- functionName %>Main = async (
|
|
65
|
+
_izContext,
|
|
66
|
+
requestParams,
|
|
67
|
+
callingFlowConfig = {},
|
|
68
|
+
//(<additionalParams>)
|
|
69
|
+
//(</additionalParams>)
|
|
70
|
+
) => {
|
|
69
71
|
|
|
70
72
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
73
|
+
try {
|
|
74
|
+
_izContext.logger.debug('<%- functionName %> _izContext: ', _izContext);
|
|
75
|
+
_izContext.logger.debug('<%- functionName %> requestParams: ', requestParams);
|
|
76
|
+
_izContext.logger.debug('<%- functionName %> callingFlowConfig: ', callingFlowConfig);
|
|
75
77
|
|
|
78
|
+
const returnFormat = requestParams.additionalRequest?.setting?.returnFormat;
|
|
79
|
+
const throwWhenNotFoundSomeRecord = requestParams.additionalRequest?.setting?.throwWhenNotFoundSomeRecord || true;
|
|
76
80
|
|
|
77
|
-
const OBJECT_TYPE = "<%- objectType %>";
|
|
78
|
-
const SERVICE_TAG = process.env.iz_serviceTag;
|
|
79
81
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
+
const OBJECT_TYPE = "<%- objectType %>";
|
|
83
|
+
const SERVICE_TAG = process.env.iz_serviceTag;
|
|
82
84
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
85
|
+
//(<beforeQuery>)
|
|
86
|
+
//(</beforeQuery>)
|
|
87
|
+
|
|
88
|
+
let objectSchema = await getObjSchemaS3WithHierarchy(
|
|
89
|
+
_izContext,
|
|
90
|
+
{
|
|
86
91
|
objectType: OBJECT_TYPE,
|
|
87
92
|
serviceTag: SERVICE_TAG
|
|
88
|
-
|
|
89
|
-
|
|
93
|
+
}
|
|
94
|
+
);
|
|
90
95
|
|
|
91
|
-
|
|
96
|
+
_izContext.logger.debug("objectSchema: ", objectSchema);
|
|
92
97
|
|
|
93
|
-
|
|
94
|
-
|
|
98
|
+
let getDataDetails = await createGetDataDetails(_izContext, objectSchema);
|
|
99
|
+
_izContext.logger.debug("getDataDetails:", getDataDetails)
|
|
95
100
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
101
|
+
// start to get data
|
|
102
|
+
let getResults = []; // for collect result data from
|
|
103
|
+
let getRecordStatus = {
|
|
104
|
+
getAtLeastOneRecord: false,
|
|
105
|
+
notFoundSomeRecord: false
|
|
106
|
+
};
|
|
102
107
|
|
|
103
|
-
|
|
104
|
-
|
|
108
|
+
await Promise.all(
|
|
109
|
+
Object.entries(getDataDetails).map(
|
|
105
110
|
async ([storageTag, getDataDetail]) => {
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
111
|
+
if (getDataDetail.storageType === consts.STORAGE_TYPES.graph) {
|
|
112
|
+
// get data from graph
|
|
113
|
+
let graphServiceName = await getGraphServiceTagWithCache(_izContext, getDataDetail.graphServiceTag);
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
let versionedDataLabels = [];
|
|
117
|
+
if (getDataDetail.versionedDatas && Object.keys(getDataDetail.versionedDatas).length) {
|
|
118
|
+
// have versionedData
|
|
119
|
+
versionedDataLabels = Object.keys(getDataDetail.versionedDatas);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
//(<beforeGetGraph>)
|
|
124
|
+
//(</beforeGetGraph>)
|
|
125
|
+
|
|
126
|
+
let dataFromGraph = await graphSharedLib.getNodeV2(
|
|
127
|
+
_izContext,
|
|
128
|
+
graphServiceName,
|
|
129
|
+
{
|
|
130
|
+
objectType: OBJECT_TYPE,
|
|
131
|
+
serviceTag: SERVICE_TAG
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
identifiers: requestParams.identifiers
|
|
135
|
+
},
|
|
136
|
+
versionedDataLabels
|
|
137
|
+
)
|
|
133
138
|
|
|
134
139
|
_izContext.logger.debug("dataFromGraphV2: ", dataFromGraph);
|
|
135
140
|
|
|
@@ -139,84 +144,88 @@ Copyright (C) 2020 Sven Mason <http: //izara.io>
|
|
|
139
144
|
getRecordStatus.notFoundSomeRecord = true
|
|
140
145
|
}
|
|
141
146
|
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
Object.assign(
|
|
146
|
-
getResults,
|
|
147
|
-
collectGetData(_izContext, dataFromGraph, getDataDetail)
|
|
148
|
-
)
|
|
147
|
+
//(<afterGetGraph>)
|
|
148
|
+
//(</afterGetGraph>)
|
|
149
149
|
|
|
150
|
+
getResults.push([dataFromGraph, getDataDetail]);
|
|
150
151
|
|
|
151
|
-
|
|
152
|
+
} else {
|
|
152
153
|
|
|
153
154
|
let identifiersForGetData = await dynamoDbIdentifiersByStorageResource(
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
155
|
+
_izContext,
|
|
156
|
+
objectSchema,
|
|
157
|
+
getDataDetail,
|
|
158
|
+
requestParams.identifiers
|
|
158
159
|
);
|
|
159
160
|
|
|
160
161
|
_izContext.logger.debug("identifiersForGetData: ", identifiersForGetData);
|
|
161
162
|
|
|
162
163
|
|
|
163
164
|
//(<beforeGetDynamoDb>)
|
|
164
|
-
|
|
165
|
+
//(</beforeGetDynamoDb>)
|
|
165
166
|
|
|
166
167
|
let dataFromDynamoDb = await dynamodbSharedLib.getItem(
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
168
|
+
_izContext,
|
|
169
|
+
await dynamodbSharedLib.tableName(_izContext, getDataDetail.tableName),
|
|
170
|
+
identifiersForGetData
|
|
170
171
|
);
|
|
171
172
|
|
|
172
173
|
_izContext.logger.debug("dataFromDynamoDb: ", dataFromDynamoDb);
|
|
173
174
|
|
|
174
175
|
|
|
175
176
|
if (dataFromDynamoDb) {
|
|
176
|
-
|
|
177
|
+
dataFromDynamoDb = await objInstanceFromobjInstanceBase(
|
|
178
|
+
_izContext,
|
|
179
|
+
{
|
|
180
|
+
objectType: OBJECT_TYPE,
|
|
181
|
+
serviceTag: SERVICE_TAG
|
|
182
|
+
},
|
|
183
|
+
dataFromDynamoDb
|
|
184
|
+
);
|
|
185
|
+
|
|
186
|
+
getRecordStatus.getAtLeastOneRecord = true;
|
|
177
187
|
} else {
|
|
178
|
-
|
|
188
|
+
getRecordStatus.notFoundSomeRecord = true;
|
|
179
189
|
}
|
|
180
190
|
|
|
181
191
|
//(<afterGetDynamoDb>)
|
|
182
|
-
|
|
192
|
+
//(</afterGetDynamoDb>)
|
|
183
193
|
|
|
184
194
|
// collect return data depend on getDataDetail
|
|
185
|
-
|
|
186
|
-
getResults,
|
|
187
|
-
collectGetData(_izContext, dataFromDynamoDb, getDataDetail)
|
|
188
|
-
);
|
|
195
|
+
getResults.push([dataFromDynamoDb, getDataDetail]);
|
|
189
196
|
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
197
|
+
}
|
|
198
|
+
})
|
|
199
|
+
);
|
|
193
200
|
|
|
194
|
-
|
|
201
|
+
_izContext.logger.debug("getRecordStatus: ", getRecordStatus);
|
|
195
202
|
|
|
196
|
-
|
|
203
|
+
if (throwWhenNotFoundSomeRecord && getRecordStatus.getAtLeastOneRecord === true && getRecordStatus.notFoundSomeRecord === true) {
|
|
197
204
|
throw Error("Not found some record while get data");
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
let getResult = collectGetData(_izContext, getResults, objectSchema, returnFormat);
|
|
208
|
+
|
|
209
|
+
return getResult;
|
|
210
|
+
} catch (err) {
|
|
211
|
+
_izContext.logger.error('error <%- firstLetterUpperCase(functionName) %>Main: ', err)
|
|
212
|
+
throw (err)
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
<%_ function firstLetterUpperCase(text){ return text.charAt(0).toUpperCase() + text.slice(1) } _%>
|
|
217
|
+
<%_ function firstLetterLowerCase(str) { return str.charAt(0).toLowerCase() + str.slice(1) } _%>
|
|
218
|
+
|
|
219
|
+
// request input
|
|
220
|
+
// {
|
|
221
|
+
// "identifiers": {
|
|
222
|
+
// "companyId": "seagame001GenerateCode2",
|
|
223
|
+
// "city": "cnxCity",
|
|
224
|
+
// "companyName": "RoyalSeafood"
|
|
225
|
+
// },
|
|
226
|
+
// "additionalRequest": {
|
|
227
|
+
// "setting": {
|
|
228
|
+
// "returnFormat": "STD" || "FULL"
|
|
229
|
+
// }
|
|
230
|
+
// }
|
|
231
|
+
// }
|
|
@@ -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
|
|
@@ -44,7 +44,7 @@ const sqsTemplatePath = path.join(__dirname, './sqsTemplate.ejs')
|
|
|
44
44
|
function dataForCreateSnsAndSqsQueueFromObjectSchema(_izContext, objectSchema, srcPath) {
|
|
45
45
|
const snsAndSqsDataArray = [];
|
|
46
46
|
for (const action of Object.values(ACTIONS)) {
|
|
47
|
-
if (objectSchema.overWriteHandlers[action]) {
|
|
47
|
+
if (objectSchema.overWriteHandlers?.[action]) {
|
|
48
48
|
for (const handler of objectSchema.overWriteHandlers[action]) {
|
|
49
49
|
const snsAndSqsData = {
|
|
50
50
|
queueName: createQueueNameForSnsAndSqsQueue(_izContext, objectSchema, action, handler, srcPath)
|
|
@@ -35,7 +35,7 @@ const templatePath = path.join(__dirname, "./template.ejs")
|
|
|
35
35
|
function createDataForCreateSourceSnsOut(_izContext, objectSchema, srcPath) {
|
|
36
36
|
const createSourceArray = [];
|
|
37
37
|
for (const action of Object.values(ACTIONS)) {
|
|
38
|
-
if (objectSchema.overWriteHandlers[action]) {
|
|
38
|
+
if (objectSchema.overWriteHandlers?.[action]) {
|
|
39
39
|
for (const handler of objectSchema.overWriteHandlers[action]) {
|
|
40
40
|
const snsOut = {
|
|
41
41
|
queueName: createQueueName(_izContext, objectSchema, action, handler, srcPath)
|
package/src/TemplateManager/src/TranslateIdReq/ProcessingTranslateIds/mainFunction/template.ejs
CHANGED
|
@@ -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,
|
|
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
|
-
|
|
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,
|