@izara_project/izara-market-library-service-schemas 1.0.11 → 1.0.13
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 +26 -49
- package/src/TemplateManager/src/PerActionEndpoint/Handler/HdrApi/data.js +4 -4
- package/src/TemplateManager/src/PerActionEndpoint/MainFunction/Create/template.ejs +3 -3
- package/src/TemplateManager/src/PerActionEndpoint/MainFunction/Get/template.ejs +148 -139
- 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/libs/GenerateCodeUtils.js +57 -0
- package/src/TemplateManager/src/PerActionEndpoint/MainFunction/Create/CreateObject_main.js +0 -760
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@izara_project/izara-market-library-service-schemas",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.13",
|
|
4
4
|
"description": "Schemas for Izara Market project",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
23
|
"@izara_project/izara-core-library-core": "^1.0.13",
|
|
24
|
-
"@izara_project/izara-core-library-
|
|
24
|
+
"@izara_project/izara-core-library-external-request": "^1.0.14",
|
|
25
25
|
"@izara_project/izara-core-library-service-schemas": "^1.0.25",
|
|
26
26
|
"@izara_project/izara-shared": "^1.0.96",
|
|
27
27
|
"ejs": "^3.1.10",
|
|
@@ -47,6 +47,10 @@ const {
|
|
|
47
47
|
|
|
48
48
|
const nodeLabelRegexPattern = "^[a-zA-Z0-9_-]+(?:\:[a-zA-Z0-9_-]+)?$"
|
|
49
49
|
|
|
50
|
+
const RETURN_GET_DATA_FORMAT = {
|
|
51
|
+
std: "STD", // { identifiers:{...}, fields:{...}} , data depend on getDataDetails
|
|
52
|
+
full: "FULL", // {storageTag:{...getResult from database}}
|
|
53
|
+
}
|
|
50
54
|
|
|
51
55
|
const schemaFunctionPerAction = {
|
|
52
56
|
[consts.ACTIONS.create]: validatorSchema.generateValidatorSchemaForCreate,
|
|
@@ -215,6 +219,20 @@ async function messageToDlq(record, messageFailError, queueUrl) {
|
|
|
215
219
|
};
|
|
216
220
|
|
|
217
221
|
|
|
222
|
+
// {
|
|
223
|
+
// [storageTag]: {
|
|
224
|
+
// storageType: 'graph',
|
|
225
|
+
// graphServiceTag: 'GraphHandler',
|
|
226
|
+
// fieldNames: [ 'companyName', 'companyId' ],
|
|
227
|
+
// versionedDatas: {
|
|
228
|
+
// ceo: [ 'name', 'ceoAddress', 'salary' ],
|
|
229
|
+
// branch: [ 'branchAddress', 'branchId' ]
|
|
230
|
+
// }
|
|
231
|
+
// versionedDataLabels:[],
|
|
232
|
+
// }
|
|
233
|
+
// }
|
|
234
|
+
|
|
235
|
+
|
|
218
236
|
/**
|
|
219
237
|
* helper function for get endpoint
|
|
220
238
|
* create get data detail for each storageTag
|
|
@@ -257,6 +275,10 @@ async function createGetDataDetails(_izContext, objectSchema) {
|
|
|
257
275
|
// collect fieldNames per storageTag
|
|
258
276
|
let storageTagFieldNames = [];
|
|
259
277
|
for (let [fieldName, fieldNameData] of Object.entries(objectSchema.fieldNames)) {
|
|
278
|
+
// if (fieldName.startsWith("versionedDataField")) {
|
|
279
|
+
// continue;
|
|
280
|
+
// }
|
|
281
|
+
|
|
260
282
|
if (fieldNameData.storageResourceTags.includes(storageTag)) {
|
|
261
283
|
storageTagFieldNames.push(fieldName);
|
|
262
284
|
}
|
|
@@ -391,11 +413,20 @@ async function createGetDataDetails(_izContext, objectSchema) {
|
|
|
391
413
|
|
|
392
414
|
_izContext.logger.debug("getDataDetailResults: ", getDataDetailResults);
|
|
393
415
|
|
|
416
|
+
for (const getDataDetail of Object.values(getDataDetailResults)) {
|
|
417
|
+
if (getDataDetail.hasOwnProperty("versionedDatas")) {
|
|
418
|
+
getDataDetail.versionedDataLabels = [];
|
|
419
|
+
for (let [versionedDataLabel, fieldNames] of Object.entries(getDataDetail.versionedDatas)) {
|
|
420
|
+
getDataDetail.versionedDataLabels.push(versionedDataLabel)
|
|
421
|
+
getDataDetail.fieldNames.push(...fieldNames);
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
|
|
394
426
|
return getDataDetailResults;
|
|
395
427
|
}
|
|
396
428
|
|
|
397
429
|
|
|
398
|
-
|
|
399
430
|
/**
|
|
400
431
|
* create dynamoDb identifiers using request param and objectSchema
|
|
401
432
|
*
|
|
@@ -518,144 +549,165 @@ async function dynamoDbIdentifiersByStorageResource(_izContext, objectSchema, ge
|
|
|
518
549
|
}
|
|
519
550
|
|
|
520
551
|
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
552
|
+
/**
|
|
553
|
+
* receive result from multiple database and create data format depend on returnFormat setting
|
|
554
|
+
*
|
|
555
|
+
* @param {object} _izContext
|
|
556
|
+
* @param {object[]} getResults
|
|
557
|
+
* @param {object} objectSchema
|
|
558
|
+
* @param {string} returnFormat
|
|
559
|
+
* @returns
|
|
560
|
+
*/
|
|
561
|
+
function collectGetData(_izContext, getResults, objectSchema, returnFormat = RETURN_GET_DATA_FORMAT.std) {
|
|
562
|
+
_izContext.logger.debug("collectGetData: ", {
|
|
563
|
+
getResults,
|
|
564
|
+
objectSchema,
|
|
565
|
+
returnFormat
|
|
566
|
+
});
|
|
567
|
+
|
|
568
|
+
if (returnFormat === "STD") {
|
|
569
|
+
return collectGetDataStdFormat(_izContext, getResults, objectSchema);
|
|
570
|
+
} else if (returnFormat === "FULL") {
|
|
571
|
+
return collectGetDataFullFormat(_izContext, getResults,)
|
|
572
|
+
} else {
|
|
573
|
+
throw new NoRetryError("invalid format");
|
|
526
574
|
}
|
|
575
|
+
}
|
|
527
576
|
|
|
528
|
-
let collectedData = {};
|
|
529
|
-
|
|
530
|
-
// if (getDataDetail.storageType === consts.STORAGE_TYPES.graph) {
|
|
531
|
-
// // collect return data form main node only form properties
|
|
532
|
-
// if (getDataResult.properties) {
|
|
533
|
-
// for (let [mainFieldName, mainFieldNameValue] of Object.entries(getDataResult.properties)) {
|
|
534
|
-
// if (getDataDetail.fieldNames.includes(mainFieldName)) {
|
|
535
|
-
// Object.assign(collectedData, { [mainFieldName]: mainFieldNameValue });
|
|
536
|
-
// }
|
|
537
|
-
// }
|
|
538
|
-
// }
|
|
539
|
-
if (getDataDetail.storageType === consts.STORAGE_TYPES.graph) {
|
|
540
|
-
if (getDataResult.objInstance) {
|
|
541
|
-
for (let [identifiersField, identifiersValues] of Object.entries(getDataResult.objInstance)) {
|
|
542
|
-
for (let [mainFieldName, mainFieldNameValue] of Object.entries(identifiersValues)) {
|
|
543
|
-
Object.assign(collectedData, {
|
|
544
|
-
[getDataDetail.graphServiceTag]: {
|
|
545
|
-
objType: {
|
|
546
|
-
|
|
547
|
-
},
|
|
548
|
-
objInstance: {
|
|
549
|
-
[mainFieldName]: mainFieldNameValue
|
|
550
|
-
}
|
|
551
|
-
}
|
|
552
|
-
})
|
|
553
|
-
}
|
|
554
|
-
}
|
|
555
|
-
}
|
|
556
577
|
|
|
578
|
+
/**
|
|
579
|
+
* helper function for collectGetData
|
|
580
|
+
*
|
|
581
|
+
* @param {object} _izContext
|
|
582
|
+
* @param {object[]} getResults
|
|
583
|
+
* @param {set} identifierFieldNames
|
|
584
|
+
* @returns
|
|
585
|
+
*/
|
|
586
|
+
function collectGetDataStdFormat(_izContext, getResults, objectSchema) {
|
|
557
587
|
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
588
|
+
let collectedData = {
|
|
589
|
+
identifiers: {},
|
|
590
|
+
fields: {}
|
|
591
|
+
};
|
|
561
592
|
|
|
562
|
-
|
|
593
|
+
const identifierFieldNames = new Set(utils.getUsedFieldNamesOfIdentifiers(_izContext, objectSchema.identifiers));
|
|
563
594
|
|
|
564
|
-
|
|
595
|
+
let addedFieldNames = new Set();
|
|
565
596
|
|
|
566
|
-
|
|
597
|
+
// if isFound === true then return null from this function
|
|
598
|
+
let isFound = false;
|
|
567
599
|
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
600
|
+
for (const [getData, getDataDetail] of getResults) {
|
|
601
|
+
if (!getData || !Object.keys(getData).length) {
|
|
602
|
+
continue;
|
|
603
|
+
}
|
|
571
604
|
|
|
572
|
-
|
|
605
|
+
// this process will add result from graph and dynamo to collectedData object by add identifiers and fieldName from getData
|
|
606
|
+
if (getDataDetail.storageType === consts.STORAGE_TYPES.graph) {
|
|
607
|
+
if (getData.objInstanceFull && Object.keys(getData.objInstanceFull).length) {
|
|
573
608
|
|
|
574
|
-
|
|
609
|
+
for (const getDetailFieldName of getDataDetail.fieldNames) {
|
|
610
|
+
if (addedFieldNames.has(getDetailFieldName)) {
|
|
611
|
+
continue;
|
|
612
|
+
}
|
|
575
613
|
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
614
|
+
if (getData.objInstanceFull.identifiers.hasOwnProperty(getDetailFieldName)) {
|
|
615
|
+
Object.assign(
|
|
616
|
+
collectedData.identifiers,
|
|
617
|
+
{ [getDetailFieldName]: getData.objInstanceFull.identifiers[getDetailFieldName] }
|
|
618
|
+
);
|
|
619
|
+
addedFieldNames.add(getDetailFieldName);
|
|
620
|
+
isFound = true;
|
|
621
|
+
} else if (getData.objInstanceFull.fields.hasOwnProperty(getDetailFieldName)) {
|
|
622
|
+
Object.assign(
|
|
623
|
+
collectedData.fields,
|
|
624
|
+
{ [getDetailFieldName]: getData.objInstanceFull.fields[getDetailFieldName] }
|
|
625
|
+
);
|
|
626
|
+
addedFieldNames.add(getDetailFieldName);
|
|
627
|
+
isFound = true;
|
|
581
628
|
}
|
|
582
629
|
}
|
|
583
630
|
}
|
|
584
|
-
}
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
// if (getDataDetail.fieldNames.includes(dynamoDbKey)) {
|
|
590
|
-
// Object.assign(collectedData, { [dynamoDbKey]: dynamoDbValue });
|
|
591
|
-
// }
|
|
592
|
-
// }
|
|
631
|
+
} else if (getDataDetail.storageType === consts.STORAGE_TYPES.dynamoDB) {
|
|
632
|
+
for (const getDetailFieldName of getDataDetail.fieldNames) {
|
|
633
|
+
if (addedFieldNames.has(getDetailFieldName)) {
|
|
634
|
+
continue;
|
|
635
|
+
}
|
|
593
636
|
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
637
|
+
if (getData.hasOwnProperty(getDetailFieldName)) {
|
|
638
|
+
if (identifierFieldNames.has(getDetailFieldName)) {
|
|
639
|
+
Object.assign(
|
|
640
|
+
collectedData.identifiers,
|
|
641
|
+
{ [getDetailFieldName]: getData[getDetailFieldName] }
|
|
642
|
+
);
|
|
643
|
+
addedFieldNames.add(getDetailFieldName);
|
|
644
|
+
isFound = true;
|
|
645
|
+
} else {
|
|
646
|
+
Object.assign(
|
|
647
|
+
collectedData.fields,
|
|
648
|
+
{ [getDetailFieldName]: getData[getDetailFieldName] }
|
|
649
|
+
);
|
|
650
|
+
addedFieldNames.add(getDetailFieldName);
|
|
651
|
+
isFound = true;
|
|
652
|
+
}
|
|
653
|
+
}
|
|
599
654
|
}
|
|
655
|
+
} else {
|
|
656
|
+
throw new NoRetryError("collectGetData unhandled storageType");
|
|
600
657
|
}
|
|
658
|
+
}
|
|
601
659
|
|
|
660
|
+
if (isFound) {
|
|
661
|
+
return collectedData;
|
|
602
662
|
} else {
|
|
603
|
-
|
|
663
|
+
return null;
|
|
604
664
|
}
|
|
605
|
-
|
|
606
|
-
return collectedData
|
|
607
665
|
}
|
|
608
666
|
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
// // collect return data form main node
|
|
620
|
-
// if (getDataResult.nodeProperties) {
|
|
621
|
-
// for (let [mainFieldName, mainFieldNameValue] of Object.entries(getDataResult.nodeProperties)) {
|
|
622
|
-
// if (getDataDetail.fieldNames.includes(mainFieldName)) {
|
|
623
|
-
// Object.assign(collectedData, { [mainFieldName]: mainFieldNameValue });
|
|
624
|
-
// }
|
|
625
|
-
// }
|
|
626
|
-
// }
|
|
667
|
+
/**
|
|
668
|
+
*
|
|
669
|
+
* helper function for collectGetData
|
|
670
|
+
*
|
|
671
|
+
* @param {object} _izContext
|
|
672
|
+
* @param {objects[]} getResults
|
|
673
|
+
* @returns
|
|
674
|
+
*/
|
|
675
|
+
function collectGetDataFullFormat(_izContext, getResults) {
|
|
676
|
+
let collectedData = {};
|
|
627
677
|
|
|
628
|
-
//
|
|
629
|
-
|
|
630
|
-
// let versionedDataLabels = Object.keys(getDataDetail.versionedDatas);
|
|
678
|
+
// if isFound === true then return null from this function
|
|
679
|
+
let isFound = false;
|
|
631
680
|
|
|
632
|
-
// for (let versionedDataLabel of versionedDataLabels) {
|
|
633
|
-
// if (getDataResult[versionedDataLabel]?.nodeProperties && Object.keys(getDataResult[versionedDataLabel].nodeProperties).length) {
|
|
634
|
-
// let neededVersionedDataFieldNames = getDataDetail.versionedDatas[versionedDataLabel];
|
|
635
681
|
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
// }
|
|
641
|
-
// }
|
|
642
|
-
// }
|
|
643
|
-
// }
|
|
682
|
+
for (const [getData, getDataDetail] of getResults) {
|
|
683
|
+
if (!getData || !Object.keys(getData).length) {
|
|
684
|
+
continue;
|
|
685
|
+
}
|
|
644
686
|
|
|
645
|
-
//
|
|
687
|
+
// this process will add result from graph and dynamo to collectedData object by add identifiers and fieldName from getData
|
|
688
|
+
if (getDataDetail.storageType === consts.STORAGE_TYPES.graph) {
|
|
689
|
+
if (getData.objInstanceFull?.identifiers && Object.keys(getData.objInstanceFull?.identifiers).length) {
|
|
690
|
+
Object.assign(collectedData, { [getDataDetail.graphServiceTag]: getData });
|
|
691
|
+
isFound = true;
|
|
692
|
+
}
|
|
693
|
+
} else if (getDataDetail.storageType === consts.STORAGE_TYPES.dynamoDB) {
|
|
646
694
|
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
695
|
+
if (getData && Object.keys(getData).length) {
|
|
696
|
+
Object.assign(collectedData, { [getDataDetail.tableName]: getData });
|
|
697
|
+
isFound = true;
|
|
698
|
+
}
|
|
699
|
+
} else {
|
|
700
|
+
throw new NoRetryError("collectGetData unhandled storageType");
|
|
701
|
+
}
|
|
702
|
+
}
|
|
652
703
|
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
704
|
+
if (isFound) {
|
|
705
|
+
return collectedData;
|
|
706
|
+
} else {
|
|
707
|
+
return null;
|
|
708
|
+
}
|
|
709
|
+
}
|
|
656
710
|
|
|
657
|
-
// return collectedData
|
|
658
|
-
// }
|
|
659
711
|
|
|
660
712
|
async function createUpdateDataDetail(_izContext, objectSchema) {
|
|
661
713
|
let getGraphDataDetails = {};
|
|
@@ -899,10 +951,11 @@ module.exports = {
|
|
|
899
951
|
validateSchemaPerRecord,
|
|
900
952
|
|
|
901
953
|
createGetDataDetails,
|
|
954
|
+
collectGetData,
|
|
955
|
+
|
|
902
956
|
generateDynamoDbIdentifiers,
|
|
903
957
|
generateDynamoDbIdentifiersWithCache,
|
|
904
958
|
dynamoDbIdentifiersByStorageResource,
|
|
905
|
-
collectGetData,
|
|
906
959
|
createUpdateDataDetail,
|
|
907
960
|
createDataDetailsLib,
|
|
908
961
|
createDeleteDataDetail
|
|
@@ -160,22 +160,6 @@ const createDeleteRelationshipCompleteHandler = require('./RelationshipPerAction
|
|
|
160
160
|
const createDeleteRelationshipCompleteSnsAndSqs = require('./RelationshipPerAction/DeleteRelationship/DeleteRelationshipComplete/sns-in-sqs/data');
|
|
161
161
|
const createDeleteRelationshipCompleteSnsOut = require('./RelationshipPerAction/DeleteRelationship/DeleteRelationshipComplete/sns-out/data');
|
|
162
162
|
|
|
163
|
-
// TranslateIdRequest
|
|
164
|
-
const createTranslateIdsCacheMainTable = require('./TranslateIdReq/TranslateIds/resourceYaml/dynamoDb/data');
|
|
165
|
-
const createTranslateIdsRequestMainFunction = require('./TranslateIdReq/TranslateIds/mainFunction/data');
|
|
166
|
-
const createTranslateIdsHandlerDsq = require('./TranslateIdReq/TranslateIds/handler/HdrDsq/data');
|
|
167
|
-
const createTranslateIdsHandlerSqs = require('./TranslateIdReq/TranslateIds/handler/HdrSqs/data');
|
|
168
|
-
const createTranslateIdFunctionYamlHdrDsq = require('./TranslateIdReq/TranslateIds/functionYaml/HdrDsq/data');
|
|
169
|
-
const createTranslateIdFunctionYamlHdrSqs = require('./TranslateIdReq/TranslateIds/functionYaml/HdrSqs/data');
|
|
170
|
-
const createSnsAndSqsTranslateId = require('./TranslateIdReq/TranslateIds/resourceYaml/sns-sqs/data');
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
// processTranslateIds
|
|
174
|
-
const createProcessTranslateIdsCompleteSnsOut = require('./TranslateIdReq/ProcessingTranslateIds/sns-out/data');
|
|
175
|
-
const createTranslateIdsProcessSnsQueue = require('./TranslateIdReq/ProcessingTranslateIds/sqs-sns/data');
|
|
176
|
-
const createTranslateIdsProcessFunctionYaml = require('./TranslateIdReq/ProcessingTranslateIds/functionYaml/data');
|
|
177
|
-
const createTranslateIdsProcessHandler = require('./TranslateIdReq/ProcessingTranslateIds/handler/dataHdrDsq');
|
|
178
|
-
const createTranslateIdsProcessMainFunction = require('./TranslateIdReq/ProcessingTranslateIds/mainFunction/data')
|
|
179
163
|
// findData
|
|
180
164
|
const createFindDataFunctionYaml = require('./FindData/FindDataYaml/data');
|
|
181
165
|
const createFindDataHandler = require('./FindData/Handler/data');
|
|
@@ -196,6 +180,11 @@ const createProcessLogicalPaginateFunctionYamlHdrSqs = require('./ProcessLogical
|
|
|
196
180
|
//get functionNameConfig
|
|
197
181
|
const functionNameConfigFile = require('./externalService/FunctionNameConfig/data')
|
|
198
182
|
|
|
183
|
+
//lib of generateCode
|
|
184
|
+
const { checkValidTableYaml } = require('./libs/GenerateCodeUtils');
|
|
185
|
+
|
|
186
|
+
const { NoRetryError } = require('@izara_project/izara-core-library-core');
|
|
187
|
+
|
|
199
188
|
/**
|
|
200
189
|
*
|
|
201
190
|
* get template and send to
|
|
@@ -217,15 +206,14 @@ async function generateCodeWithTemplate(_izContext, objSchemaPath) {
|
|
|
217
206
|
|
|
218
207
|
// define path for store yml file
|
|
219
208
|
const GENERATECODE_SOURCE_PATH = {
|
|
220
|
-
appYaml: join(saveFilePath, `../sls_yaml/generatedCode/`),
|
|
221
|
-
resourceYaml: join(saveFilePath, `../../resource/sls_yaml/generatedCode/`),
|
|
222
|
-
lambdaPerAction: join(saveFilePath, '../src/generatedCode/ObjectTypePerActionEndpoint/'),
|
|
209
|
+
appYaml: join(saveFilePath, `../sls_yaml/generatedCode/source/`),
|
|
210
|
+
resourceYaml: join(saveFilePath, `../../resource/sls_yaml/generatedCode/source/`),
|
|
211
|
+
lambdaPerAction: join(saveFilePath, '../src/generatedCode/ObjectTypePerActionEndpoint/source/'),
|
|
223
212
|
externalService: join(saveFilePath, '../initial_setup/generatedCode/source/'),
|
|
224
213
|
resourceLocation: join(saveFilePath, 'src/generatedCode/perAction/source/'),
|
|
225
214
|
lamdaPerCombindActionPath: join(saveFilePath, `/generatedCode/lamdaPerCombindAction/source/`), // test
|
|
226
|
-
lambdaPerObjectTypePath: join(saveFilePath, `/generatedCode/lambdaPerObjectType/`), // test
|
|
227
|
-
updateRelationship: join(saveFilePath, `../src/generatedCode/RelationshipPerAction/`),
|
|
228
|
-
translateId: join(saveFilePath, `../src/generatedCode/TranslateId/`)
|
|
215
|
+
lambdaPerObjectTypePath: join(saveFilePath, `/generatedCode/lambdaPerObjectType/source/`), // test
|
|
216
|
+
updateRelationship: join(saveFilePath, `../src/generatedCode/RelationshipPerAction/source/`),
|
|
229
217
|
};
|
|
230
218
|
|
|
231
219
|
|
|
@@ -248,6 +236,9 @@ async function generateCodeWithTemplate(_izContext, objSchemaPath) {
|
|
|
248
236
|
|
|
249
237
|
let createSourceParams = [];
|
|
250
238
|
|
|
239
|
+
// use to check dynamoDB table yaml, to prevent duplicate tableName
|
|
240
|
+
let createdTableYaml = {};
|
|
241
|
+
|
|
251
242
|
for (const relTag in allObjectRelationships) {
|
|
252
243
|
// const relTagData = allObjectRelationships[relTag];
|
|
253
244
|
|
|
@@ -288,12 +279,19 @@ async function generateCodeWithTemplate(_izContext, objSchemaPath) {
|
|
|
288
279
|
const createFunctionYaml = [...createFunctionYamlHdrApi, ...createFunctionYamlHdrDsq, ...createFunctionYamlHdrInv, ...createFunctionYamlHdrSqs];
|
|
289
280
|
|
|
290
281
|
// generate Resource ..via dynamoDb sns-in-sqs sns-put
|
|
291
|
-
|
|
282
|
+
let [createResourceDynamo, newCreatedTableYaml] = checkValidTableYaml(
|
|
283
|
+
_izContext,
|
|
284
|
+
createSourceDataDynamoDB(_izContext, objectSchema, saveFilePath),
|
|
285
|
+
createdTableYaml
|
|
286
|
+
);
|
|
287
|
+
|
|
288
|
+
createdTableYaml = newCreatedTableYaml;
|
|
289
|
+
_izContext.logger.debug("createResourceDynamo: ", createResourceDynamo);
|
|
290
|
+
|
|
292
291
|
const createResourceSnsInSqs = createSourceSnsAndSqs(_izContext, objectSchema, saveFilePath);
|
|
293
292
|
const createResourceSnsOut = createDataForCreateSourceSnsOut(_izContext, objectSchema, saveFilePath);
|
|
294
293
|
|
|
295
294
|
// translateIdsMainFunction
|
|
296
|
-
const translateIdsMainFunction = await createTranslateIdsRequestMainFunction(_izContext, objectSchema, saveFilePath);
|
|
297
295
|
|
|
298
296
|
// wrap main Resource
|
|
299
297
|
const createMainResource = [...createResourceDynamo, ...createResourceSnsInSqs, ...createResourceSnsOut];
|
|
@@ -301,11 +299,10 @@ async function generateCodeWithTemplate(_izContext, objSchemaPath) {
|
|
|
301
299
|
|
|
302
300
|
createSourceParams = createSourceParams.concat([
|
|
303
301
|
// ...createSourceMainResourcesObjectSchema,
|
|
304
|
-
...createSourceHandler,
|
|
305
|
-
...createMainFunction,
|
|
306
|
-
...createFunctionYaml,
|
|
307
|
-
...createMainResource,
|
|
308
|
-
...translateIdsMainFunction,
|
|
302
|
+
...createSourceHandler, // create handler function
|
|
303
|
+
...createMainFunction, // create main function
|
|
304
|
+
...createFunctionYaml, // create function.yaml
|
|
305
|
+
...createMainResource, // create resource yaml
|
|
309
306
|
]);
|
|
310
307
|
|
|
311
308
|
// console.log("createSourceParams after concat: ", createSourceParams);
|
|
@@ -446,24 +443,6 @@ async function generateCodeWithTemplate(_izContext, objSchemaPath) {
|
|
|
446
443
|
|
|
447
444
|
const deleteRelationshipCompleteData = [...deleteRelationshipCompleteFunctionYaml, ...deleteRelationshipCompleteMainFunction, ...deleteRelationshipCompleteHandler, ...deleteRelationshipCompleteSnsAndSqs, ...deleteRelationshipCompleteSnsOut]
|
|
448
445
|
|
|
449
|
-
const translateIdsCacheIdsMainTable = createTranslateIdsCacheMainTable(_izContext, saveFilePath);
|
|
450
|
-
const translateIdsHandlerFunctionDsq = createTranslateIdsHandlerDsq(_izContext, saveFilePath);
|
|
451
|
-
const translateIdsHandlerFunctionSqs = createTranslateIdsHandlerSqs(_izContext, saveFilePath);
|
|
452
|
-
const translateIdsFunctionYamlDsq = createTranslateIdFunctionYamlHdrDsq(_izContext, saveFilePath);
|
|
453
|
-
const translateIdsFunctionYamlSqs = createTranslateIdFunctionYamlHdrSqs(_izContext, saveFilePath);
|
|
454
|
-
const translateIdsSnsAndSqsResourceQueue = createSnsAndSqsTranslateId(_izContext, saveFilePath);
|
|
455
|
-
|
|
456
|
-
const createTranslateIdsResourece = [...translateIdsCacheIdsMainTable, ...translateIdsHandlerFunctionDsq, ...translateIdsHandlerFunctionSqs,
|
|
457
|
-
...translateIdsFunctionYamlDsq, ...translateIdsFunctionYamlSqs, ...translateIdsSnsAndSqsResourceQueue
|
|
458
|
-
]
|
|
459
|
-
|
|
460
|
-
const translateIdsProcessingSnsOut = createProcessTranslateIdsCompleteSnsOut(_izContext, saveFilePath);
|
|
461
|
-
const translateIdsProcessingQueue = createTranslateIdsProcessSnsQueue(_izContext, saveFilePath);
|
|
462
|
-
const translateIdsProcessingFunctionYaml = createTranslateIdsProcessFunctionYaml(_izContext, saveFilePath);
|
|
463
|
-
const translateIdsProcessingHandler = createTranslateIdsProcessHandler(_izContext, saveFilePath);
|
|
464
|
-
const translateIdsProcessingMainFunction = createTranslateIdsProcessMainFunction(_izContext, saveFilePath);
|
|
465
|
-
const createTranslateIdsProcessing = [...translateIdsProcessingQueue, ...translateIdsProcessingFunctionYaml, ...translateIdsProcessingHandler, ...translateIdsProcessingMainFunction, ...translateIdsProcessingSnsOut]
|
|
466
|
-
|
|
467
446
|
const findDataHandlerSqs = createFindDataHandler(_izContext, saveFilePath);
|
|
468
447
|
const findDataMainFunction = await createFindDataMainFunction(_izContext, saveFilePath);
|
|
469
448
|
|
|
@@ -494,8 +473,6 @@ async function generateCodeWithTemplate(_izContext, objSchemaPath) {
|
|
|
494
473
|
createSourceParams.push(
|
|
495
474
|
...updateRelationshipSchemaDatas,
|
|
496
475
|
...createRelationshipSchemaDatas,
|
|
497
|
-
...createTranslateIdsResourece,
|
|
498
|
-
...createTranslateIdsProcessing,
|
|
499
476
|
...deleteRelationshipData,
|
|
500
477
|
...deleteRelationshipCompleteData
|
|
501
478
|
)
|
|
@@ -28,7 +28,7 @@ const templatePath = path.join(__dirname, "./template.ejs")
|
|
|
28
28
|
|
|
29
29
|
/**
|
|
30
30
|
* receive objectSchema
|
|
31
|
-
* create data for
|
|
31
|
+
* create data for hdrApi template
|
|
32
32
|
*
|
|
33
33
|
* @param {Object} objectSchema
|
|
34
34
|
* @return {{ templatePath, templateData, setting } }
|
|
@@ -38,10 +38,10 @@ function data(_izContext, objectSchema, srcPath) {
|
|
|
38
38
|
|
|
39
39
|
for (const action of Object.values(ACTIONS)) {
|
|
40
40
|
if (objectSchema.overWriteHandlers?.[action]) {
|
|
41
|
-
// if have overWriteHander of action check
|
|
41
|
+
// if have overWriteHander of action check hdrApi inside
|
|
42
42
|
if (objectSchema.overWriteHandlers[action].includes(HANDLER.hdrApi)) {
|
|
43
43
|
// create template data
|
|
44
|
-
const createSourceParam = createParamForCreateSource(objectSchema, action, HANDLER.
|
|
44
|
+
const createSourceParam = createParamForCreateSource(objectSchema, action, HANDLER.hdrApi, srcPath)
|
|
45
45
|
createSourceArray.push(createSourceParam)
|
|
46
46
|
}
|
|
47
47
|
} else {
|
|
@@ -49,7 +49,7 @@ function data(_izContext, objectSchema, srcPath) {
|
|
|
49
49
|
const defaultHandler = DEFAULT_HANDLER_PER_ACTION[action]
|
|
50
50
|
if (defaultHandler.includes(HANDLER.hdrApi)) {
|
|
51
51
|
// create template data and object for create source
|
|
52
|
-
const createSourceParam = createParamForCreateSource(objectSchema, action, HANDLER.
|
|
52
|
+
const createSourceParam = createParamForCreateSource(objectSchema, action, HANDLER.hdrApi, srcPath)
|
|
53
53
|
createSourceArray.push(createSourceParam)
|
|
54
54
|
}
|
|
55
55
|
}
|
|
@@ -95,7 +95,7 @@ module.exports.<%- functionName %>Main = async (
|
|
|
95
95
|
|
|
96
96
|
let errorsFound = [];
|
|
97
97
|
|
|
98
|
-
_izContext.correlationIds.set(coreConsts.BASE_USER_ID, "BasDev");
|
|
98
|
+
// _izContext.correlationIds.set(coreConsts.BASE_USER_ID, "BasDev");
|
|
99
99
|
const userId = _izContext.correlationIds.get(coreConsts.BASE_USER_ID);
|
|
100
100
|
if (!userId) {
|
|
101
101
|
errorsFound.push("Not have userId")
|
|
@@ -211,7 +211,7 @@ module.exports.<%- functionName %>Main = async (
|
|
|
211
211
|
_izContext.logger.debug("filteredRequiredOnCreatedLinks", filteredRequiredOnCreatedLinks);
|
|
212
212
|
|
|
213
213
|
if (filteredRequiredOnCreatedLinks.length) {
|
|
214
|
-
if (!requestParams.relationships.length) {
|
|
214
|
+
if (!requestParams.relationships || !requestParams.relationships.length) {
|
|
215
215
|
// in case not send relationship to create with
|
|
216
216
|
for (const requireLink of filteredRequiredOnCreatedLinks) {
|
|
217
217
|
errorsFound.push(`missing required relationship of relType ${JSON.stringify(requireLink.relType)} when create`)
|
|
@@ -279,7 +279,7 @@ module.exports.<%- functionName %>Main = async (
|
|
|
279
279
|
let allAwaitingStepsId = [];
|
|
280
280
|
|
|
281
281
|
// validate single identifiers
|
|
282
|
-
if (objectSchemas.identifiers.length === 1 && !objectSchemas.identifiers.hasOwnProperty("fieldNames")) {
|
|
282
|
+
if (objectSchemas.identifiers.length === 1 && !objectSchemas.identifiers[0].hasOwnProperty("fieldNames")) {
|
|
283
283
|
|
|
284
284
|
const identifier = objectSchemas.identifiers[0];
|
|
285
285
|
_izContext.logger.debug(":::::case single identifer:::::", identifier);
|