@izara_project/izara-core-generate-service-code 1.0.17 → 1.0.19
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
|
@@ -60,7 +60,10 @@ async function data(_izContext, allIntTestConfig, srcPath) {
|
|
|
60
60
|
// 'testConfig.seedDataConfig[seedDataTag]',
|
|
61
61
|
// testConfig.seedDataConfig[seedDataTag]
|
|
62
62
|
// );
|
|
63
|
-
if (
|
|
63
|
+
if (
|
|
64
|
+
testConfig.seedDataConfig.hasOwnProperty(seedDataTag) &&
|
|
65
|
+
testConfig.seedDataConfig[seedDataTag].length > 0
|
|
66
|
+
) {
|
|
64
67
|
baseIntTest[seedDataTag] = testConfig.seedDataConfig[seedDataTag];
|
|
65
68
|
} else {
|
|
66
69
|
baseIntTest[seedDataTag] = [];
|
|
@@ -157,17 +160,25 @@ async function data(_izContext, allIntTestConfig, srcPath) {
|
|
|
157
160
|
);
|
|
158
161
|
if (dynamoEventStage.length > 0) {
|
|
159
162
|
// baseIntTest.stage[currentStageIdx]["dynamodbOutputEventIdentifiers"] = dynamoEventStage;
|
|
160
|
-
stages[currentStageIdx]['dynamodbOutputEventIdentifiers'] =
|
|
163
|
+
stages[currentStageIdx]['dynamodbOutputEventIdentifiers'] =
|
|
164
|
+
dynamoEventStage;
|
|
161
165
|
}
|
|
162
166
|
}
|
|
163
167
|
|
|
164
168
|
// generatedSeedData
|
|
165
|
-
if (
|
|
166
|
-
|
|
169
|
+
if (
|
|
170
|
+
stage.generatedSeedData &&
|
|
171
|
+
Object.keys(stage.generatedSeedData).length > 0
|
|
172
|
+
) {
|
|
173
|
+
for (const generateSeedType of Object.values(
|
|
174
|
+
GENERATE_SEED_DATA_TYPE
|
|
175
|
+
)) {
|
|
167
176
|
if (stage.generatedSeedData.hasOwnProperty(generateSeedType)) {
|
|
168
177
|
// baseIntTest.stage[currentStageIdx]["generateSeedDatas"] = {
|
|
169
|
-
stages[currentStageIdx]['
|
|
170
|
-
[generateSeedType]: [
|
|
178
|
+
stages[currentStageIdx]['generatedSeedData'] = {
|
|
179
|
+
[generateSeedType]: [
|
|
180
|
+
...stage.generatedSeedData[generateSeedType]
|
|
181
|
+
]
|
|
171
182
|
};
|
|
172
183
|
}
|
|
173
184
|
}
|
|
@@ -20,13 +20,9 @@ import sqsSharedLib from '@izara_project/izara-core-library-sqs';
|
|
|
20
20
|
import dynamodbSharedLib from '@izara_project/izara-core-library-dynamodb';
|
|
21
21
|
import asyncFlowSharedLib from '@izara_project/izara-core-library-asynchronous-flow';
|
|
22
22
|
|
|
23
|
-
import {
|
|
24
|
-
sqs
|
|
25
|
-
} from '@izara_project/izara-core-library-external-request';
|
|
23
|
+
import { sqs } from '@izara_project/izara-core-library-external-request';
|
|
26
24
|
|
|
27
|
-
import {
|
|
28
|
-
NoRetryError
|
|
29
|
-
} from '@izara_project/izara-core-library-core';
|
|
25
|
+
import { NoRetryError } from '@izara_project/izara-core-library-core';
|
|
30
26
|
|
|
31
27
|
// set query limit
|
|
32
28
|
const limit = 2;
|
|
@@ -38,9 +34,11 @@ const limit = 2;
|
|
|
38
34
|
* @param {string} tableName
|
|
39
35
|
* @param {string} partitionKeyFieldName
|
|
40
36
|
* @param {string} sortKeyFieldName
|
|
37
|
+
* @param {Object} dynamoDbIdentifiers
|
|
41
38
|
* @param {string} comparison
|
|
42
39
|
* @param {Object} startKey
|
|
43
40
|
* @param {string} overwriteUniqueRequestId
|
|
41
|
+
* @param {boolean} overwriteCache
|
|
44
42
|
* @param {string} callingFlow
|
|
45
43
|
*
|
|
46
44
|
* @returns {string} description of return value
|
|
@@ -52,46 +50,52 @@ export default async function paginateProcessLogical(
|
|
|
52
50
|
tableName,
|
|
53
51
|
partitionKeyFieldName,
|
|
54
52
|
sortKeyFieldName,
|
|
53
|
+
dynamoDbIdentifiers,
|
|
55
54
|
comparison, // optional
|
|
56
55
|
startKey, // optional
|
|
57
56
|
overwriteUniqueRequestId, // optional
|
|
57
|
+
overWriteCache,
|
|
58
58
|
callingFlow // optional
|
|
59
59
|
) {
|
|
60
|
-
|
|
61
60
|
try {
|
|
62
|
-
|
|
63
|
-
_izContext.logger.debug(
|
|
64
|
-
'----- PaginateProcessLogical event params -----', {
|
|
61
|
+
_izContext.logger.debug('----- PaginateProcessLogical event params -----', {
|
|
65
62
|
logicalResultId: logicalResultId,
|
|
66
63
|
tableName: tableName,
|
|
67
64
|
partitionKeyFieldName: partitionKeyFieldName,
|
|
68
65
|
sortKeyFieldName: sortKeyFieldName,
|
|
66
|
+
dynamoDbIdentifiers: dynamoDbIdentifiers,
|
|
69
67
|
comparison: comparison,
|
|
70
68
|
startKey: startKey,
|
|
71
69
|
overwriteUniqueRequestId: overwriteUniqueRequestId,
|
|
70
|
+
overWriteCache: overWriteCache,
|
|
72
71
|
callingFlow: callingFlow
|
|
73
72
|
});
|
|
74
73
|
|
|
75
74
|
// Check/Create logicalResultsMain
|
|
76
75
|
let [checkUniqueRequestProcessingStatus, logicalResultsMain] =
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
76
|
+
await asyncFlowSharedLib.checkUniqueRequestProcessing(
|
|
77
|
+
_izContext,
|
|
78
|
+
'LogicalResultsMain',
|
|
79
|
+
{
|
|
80
|
+
logicalResultId: logicalResultId
|
|
81
|
+
},
|
|
82
|
+
'paginateProcessLogical',
|
|
83
|
+
overwriteUniqueRequestId
|
|
84
|
+
);
|
|
85
|
+
_izContext.logger.debug('After check uniqueRequestProcessingStatus:', {
|
|
86
86
|
checkUniqueRequestProcessingStatus: checkUniqueRequestProcessingStatus,
|
|
87
87
|
logicalResultsMain: logicalResultsMain
|
|
88
88
|
});
|
|
89
89
|
|
|
90
|
-
if (checkUniqueRequestProcessingStatus ==
|
|
91
|
-
return
|
|
92
|
-
|
|
90
|
+
if (checkUniqueRequestProcessingStatus == 'stop') {
|
|
91
|
+
return {
|
|
92
|
+
returnResponse: 'process already stop'
|
|
93
|
+
};
|
|
94
|
+
} else if (checkUniqueRequestProcessingStatus == 'recordNotFound') {
|
|
93
95
|
// should always have unless another request already completed it, in which case nothing to do
|
|
94
|
-
return
|
|
96
|
+
return {
|
|
97
|
+
returnResponse: 'record not found'
|
|
98
|
+
};
|
|
95
99
|
}
|
|
96
100
|
|
|
97
101
|
let errorsFound = [];
|
|
@@ -100,11 +104,11 @@ export default async function paginateProcessLogical(
|
|
|
100
104
|
logicalResultId,
|
|
101
105
|
logicalResultsMain.logicalElement,
|
|
102
106
|
logicalResultsMain.objType,
|
|
107
|
+
overWriteCache,
|
|
103
108
|
callingFlow,
|
|
104
|
-
|
|
109
|
+
'error'
|
|
105
110
|
];
|
|
106
111
|
|
|
107
|
-
const partitionKeyValue = logicalResultsMain.logicalElement.partitionKey;
|
|
108
112
|
let queryElements = {
|
|
109
113
|
limit: limit
|
|
110
114
|
};
|
|
@@ -118,60 +122,101 @@ export default async function paginateProcessLogical(
|
|
|
118
122
|
);
|
|
119
123
|
|
|
120
124
|
if (startKey === false) {
|
|
121
|
-
throw new NoRetryError(
|
|
125
|
+
throw new NoRetryError('split processing received invalid startKey');
|
|
122
126
|
}
|
|
123
|
-
_izContext.logger.debug(
|
|
127
|
+
_izContext.logger.debug('startKey :', startKey);
|
|
124
128
|
|
|
125
129
|
if (startKey) {
|
|
126
|
-
queryElements[
|
|
130
|
+
queryElements['exclusiveStartKey'] = {
|
|
127
131
|
[partitionKeyFieldName]: startKey[partitionKeyFieldName],
|
|
128
132
|
[sortKeyFieldName]: startKey[sortKeyFieldName]
|
|
129
|
-
}
|
|
130
|
-
}
|
|
133
|
+
};
|
|
134
|
+
}
|
|
131
135
|
|
|
132
136
|
if (comparison) {
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
queryElements["sortKeyCondition"] = {
|
|
137
|
+
queryElements['sortKeyCondition'] = {
|
|
136
138
|
comparison: comparison,
|
|
137
139
|
name: sortKeyFieldName,
|
|
138
|
-
value:
|
|
140
|
+
value: dynamoDbIdentifiers[sortKeyFieldName]
|
|
139
141
|
};
|
|
140
142
|
}
|
|
141
143
|
|
|
142
144
|
let queryDatas = await dynamodbSharedLib.query(
|
|
143
145
|
_izContext,
|
|
144
|
-
await dynamodbSharedLib.tableName(_izContext, tableName),
|
|
145
|
-
|
|
146
|
+
await dynamodbSharedLib.tableName(_izContext, tableName),
|
|
147
|
+
{
|
|
148
|
+
[partitionKeyFieldName]: dynamoDbIdentifiers[partitionKeyFieldName]
|
|
146
149
|
},
|
|
147
150
|
queryElements
|
|
148
|
-
)
|
|
149
|
-
_izContext.logger.debug(
|
|
151
|
+
);
|
|
152
|
+
_izContext.logger.debug('queryDatas result: ', queryDatas);
|
|
150
153
|
|
|
151
154
|
if (!startKey && queryDatas.Items.length == 0) {
|
|
152
|
-
_izContext.logger.debug(`can't find data in table ${tableName}`)
|
|
153
|
-
errorsFound.push(`can't find data in table ${tableName}`)
|
|
154
|
-
standardErrorParams.push(errorsFound)
|
|
155
|
-
await logicalResultsSharedLib.completeLogicalResultsMain(
|
|
156
|
-
standardErrorParams
|
|
157
|
-
|
|
155
|
+
_izContext.logger.debug(`can't find data in table ${tableName}`);
|
|
156
|
+
errorsFound.push(`can't find data in table ${tableName}`);
|
|
157
|
+
standardErrorParams.push(errorsFound);
|
|
158
|
+
await logicalResultsSharedLib.completeLogicalResultsMain(
|
|
159
|
+
...standardErrorParams
|
|
160
|
+
);
|
|
161
|
+
return {
|
|
162
|
+
returnResponse: 'Cannot find data in table'
|
|
163
|
+
};
|
|
158
164
|
}
|
|
159
165
|
|
|
160
|
-
|
|
166
|
+
// For conditionalFieldValues
|
|
167
|
+
let objInstanceBases = queryDatas.Items;
|
|
168
|
+
const conditionalFieldValues =
|
|
169
|
+
logicalResultsMain.logicalElement.conditionalFieldValues;
|
|
170
|
+
|
|
171
|
+
if (
|
|
172
|
+
Array.isArray(conditionalFieldValues) &&
|
|
173
|
+
conditionalFieldValues.length > 0
|
|
174
|
+
) {
|
|
175
|
+
for (const conditionalFieldValue of conditionalFieldValues) {
|
|
176
|
+
_izContext.logger.debug(
|
|
177
|
+
'conditionalFieldValue: ',
|
|
178
|
+
conditionalFieldValue
|
|
179
|
+
);
|
|
180
|
+
|
|
181
|
+
let conditionalFieldName = conditionalFieldValue.fieldName;
|
|
182
|
+
|
|
183
|
+
if (conditionalFieldValue.hasOwnProperty('includeValues')) {
|
|
184
|
+
let includeValues = conditionalFieldValue.includeValues; // array
|
|
185
|
+
|
|
186
|
+
objInstanceBases = objInstanceBases.filter(objInstanceBase => {
|
|
187
|
+
return includeValues.includes(
|
|
188
|
+
objInstanceBase[conditionalFieldName]
|
|
189
|
+
);
|
|
190
|
+
});
|
|
191
|
+
} else if (conditionalFieldValue.hasOwnProperty('excludeValues')) {
|
|
192
|
+
let excludeValues = conditionalFieldValue.excludeValues; // array
|
|
193
|
+
|
|
194
|
+
objInstanceBases = objInstanceBases.filter(objInstanceBase => {
|
|
195
|
+
return !excludeValues.includes(
|
|
196
|
+
objInstanceBase[conditionalFieldName]
|
|
197
|
+
);
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
_izContext.logger.debug(
|
|
202
|
+
'objInstanceBases after conditionalFieldValues: ',
|
|
203
|
+
objInstanceBases
|
|
204
|
+
);
|
|
205
|
+
}
|
|
161
206
|
|
|
207
|
+
for (const objInstanceBase of objInstanceBases) {
|
|
162
208
|
await logicalResultsSharedLib.saveLogicalData(
|
|
163
209
|
_izContext,
|
|
164
210
|
logicalResultId,
|
|
165
211
|
logicalResultsMain.objType,
|
|
166
212
|
objInstanceBase
|
|
167
|
-
)
|
|
213
|
+
);
|
|
168
214
|
}
|
|
169
215
|
|
|
170
|
-
if (queryDatas.hasOwnProperty(
|
|
171
|
-
|
|
216
|
+
if (queryDatas.hasOwnProperty('LastEvaluatedKey')) {
|
|
172
217
|
if (!overwriteUniqueRequestId) {
|
|
173
|
-
overwriteUniqueRequestId = _izContext.uniqueRequestId
|
|
174
|
-
}
|
|
218
|
+
overwriteUniqueRequestId = _izContext.uniqueRequestId;
|
|
219
|
+
}
|
|
175
220
|
|
|
176
221
|
let continuePaginationMsg = {
|
|
177
222
|
MessageBody: JSON.stringify({
|
|
@@ -179,39 +224,45 @@ export default async function paginateProcessLogical(
|
|
|
179
224
|
tableName: tableName,
|
|
180
225
|
partitionKeyFieldName: partitionKeyFieldName,
|
|
181
226
|
sortKeyFieldName: sortKeyFieldName,
|
|
227
|
+
dynamoDbIdentifiers: dynamoDbIdentifiers,
|
|
182
228
|
comparison: comparison,
|
|
183
|
-
overwriteUniqueRequestId: overwriteUniqueRequestId,
|
|
184
229
|
startKey: queryDatas.LastEvaluatedKey,
|
|
230
|
+
overwriteUniqueRequestId: overwriteUniqueRequestId,
|
|
185
231
|
overWriteCache: overWriteCache,
|
|
186
232
|
callingFlow: callingFlow
|
|
187
233
|
}),
|
|
188
|
-
QueueUrl: await sqsSharedLib.sqsQueueUrl(
|
|
189
|
-
|
|
234
|
+
QueueUrl: await sqsSharedLib.sqsQueueUrl(
|
|
235
|
+
_izContext,
|
|
236
|
+
'PaginateProcessLogicalHdrDsq'
|
|
237
|
+
)
|
|
190
238
|
};
|
|
191
239
|
|
|
192
|
-
_izContext.logger.debug(
|
|
193
|
-
|
|
240
|
+
_izContext.logger.debug(
|
|
241
|
+
'continuePaginationMessage: ',
|
|
242
|
+
continuePaginationMsg
|
|
243
|
+
);
|
|
194
244
|
await sqs.sendMessage(_izContext, continuePaginationMsg);
|
|
195
245
|
|
|
196
|
-
return
|
|
197
|
-
|
|
246
|
+
return {
|
|
247
|
+
returnResponse: 'Continue PaginateProcessLogical'
|
|
248
|
+
};
|
|
198
249
|
} else {
|
|
199
|
-
|
|
200
250
|
await logicalResultsSharedLib.completeLogicalResultsMain(
|
|
201
251
|
_izContext,
|
|
202
252
|
logicalResultId,
|
|
203
253
|
logicalResultsMain.logicalElement,
|
|
204
254
|
logicalResultsMain.objType,
|
|
255
|
+
overWriteCache,
|
|
205
256
|
callingFlow,
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
)
|
|
257
|
+
'complete'
|
|
258
|
+
);
|
|
209
259
|
}
|
|
210
260
|
|
|
211
|
-
return
|
|
212
|
-
|
|
261
|
+
return {
|
|
262
|
+
returnResponse: 'Function PaginateProcessLogical is Finished'
|
|
263
|
+
};
|
|
213
264
|
} catch (err) {
|
|
214
265
|
_izContext.logger.error('error PaginateProcessLogicalMain: ', err);
|
|
215
|
-
throw
|
|
266
|
+
throw err;
|
|
216
267
|
}
|
|
217
|
-
}
|
|
268
|
+
}
|