@izara_project/izara-market-library-service-schemas 1.0.4 → 1.0.6
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/index.js +2 -1
- package/src/GenerateCodeLibs/src/Consts.js +20 -5
- package/src/GenerateCodeLibs/src/GenerateCodeLibs.js +298 -12
- package/src/GenerateCodeLibs/src/TranslateIdsLibs.js +89 -0
- package/src/MainLibs/src/Utils.js +10 -0
- package/src/TemplateManager/src/CreateRelationship/createRelationship/functionYaml/HdrApi/data.js +119 -0
- package/src/TemplateManager/src/CreateRelationship/createRelationship/functionYaml/HdrDsq/data.js +133 -0
- package/src/TemplateManager/src/CreateRelationship/createRelationship/functionYaml/HdrInv/data.js +120 -0
- package/src/TemplateManager/src/CreateRelationship/createRelationship/functionYaml/HdrSqs/data.js +133 -0
- package/src/TemplateManager/src/CreateRelationship/createRelationship/mainFunction/data.js +59 -0
- package/src/TemplateManager/src/CreateRelationship/createRelationship/mainFunction/template.ejs +340 -0
- package/src/TemplateManager/src/CreateRelationship/createRelationship/perAction/HdrApi/data.js +58 -0
- package/src/TemplateManager/src/CreateRelationship/createRelationship/perAction/HdrApi/request.json +0 -0
- package/src/TemplateManager/src/CreateRelationship/createRelationship/perAction/HdrApi/template.ejs +120 -0
- package/src/TemplateManager/src/CreateRelationship/createRelationship/perAction/HdrDsq/data.js +59 -0
- package/src/TemplateManager/src/CreateRelationship/createRelationship/perAction/HdrDsq/request.json +0 -0
- package/src/TemplateManager/src/CreateRelationship/createRelationship/perAction/HdrDsq/template.ejs +167 -0
- package/src/TemplateManager/src/CreateRelationship/createRelationship/perAction/HdrInv/data.js +60 -0
- package/src/TemplateManager/src/CreateRelationship/createRelationship/perAction/HdrInv/request.json +0 -0
- package/src/TemplateManager/src/CreateRelationship/createRelationship/perAction/HdrInv/template.ejs +107 -0
- package/src/TemplateManager/src/CreateRelationship/createRelationship/perAction/HdrSqs/data.js +60 -0
- package/src/TemplateManager/src/CreateRelationship/createRelationship/perAction/HdrSqs/request.json +0 -0
- package/src/TemplateManager/src/CreateRelationship/createRelationship/perAction/HdrSqs/template.ejs +146 -0
- package/src/TemplateManager/src/CreateRelationship/createRelationship/perAction/request.json +30 -0
- package/src/TemplateManager/src/CreateRelationship/createRelationship/sns-in-sqs/data.js +78 -0
- package/src/TemplateManager/src/CreateRelationship/createRelationshipComplete/functionYaml/data.js +133 -0
- package/src/TemplateManager/src/CreateRelationship/createRelationshipComplete/functionYaml/request.json +0 -0
- package/src/TemplateManager/src/CreateRelationship/createRelationshipComplete/functionYaml/template.ejs +33 -0
- package/src/TemplateManager/src/CreateRelationship/createRelationshipComplete/handler/HdrSqs/data.js +61 -0
- package/src/TemplateManager/src/CreateRelationship/createRelationshipComplete/handler/HdrSqs/request.json +0 -0
- package/src/TemplateManager/src/CreateRelationship/createRelationshipComplete/handler/HdrSqs/template.ejs +125 -0
- package/src/TemplateManager/src/CreateRelationship/createRelationshipComplete/mainFunction/data.js +56 -0
- package/src/TemplateManager/src/CreateRelationship/createRelationshipComplete/mainFunction/request.json +0 -0
- package/src/TemplateManager/src/CreateRelationship/createRelationshipComplete/mainFunction/template.ejs +137 -0
- package/src/TemplateManager/src/CreateRelationship/createRelationshipComplete/sns-in-sqs/data.js +72 -0
- package/src/TemplateManager/src/CreateRelationship/createRelationshipComplete/sns-in-sqs/request.json +0 -0
- package/src/TemplateManager/src/CreateRelationship/createRelationshipComplete/sns-in-sqs/template.ejs +47 -0
- package/src/TemplateManager/src/CreateRelationship/createRelationshipComplete/sns-out/data.js +72 -0
- package/src/TemplateManager/src/CreateRelationship/createRelationshipComplete/sns-out/request.json +0 -0
- package/src/TemplateManager/src/FindData/FindDataYaml/data.js +188 -0
- package/src/TemplateManager/src/FindData/FindDataYaml/template.ejs +27 -0
- package/src/TemplateManager/src/FindData/GetByStorage/getByDynamo.ejs +53 -0
- package/src/TemplateManager/src/FindData/GetByStorage/getByGraph.ejs +99 -0
- package/src/TemplateManager/src/FindData/Handler/data.js +48 -0
- package/src/TemplateManager/src/FindData/Handler/template.ejs +140 -0
- package/src/TemplateManager/src/FindData/mainFunction/data.js +279 -0
- package/src/TemplateManager/src/FindData/mainFunction/template.ejs +155 -0
- package/src/TemplateManager/src/GenerateCode(Old).js +1 -1
- package/src/TemplateManager/src/GenerateCode.js +205 -45
- package/src/TemplateManager/src/OutPerActionComplete/OutCreateComplete/functionYaml/data.js +98 -0
- package/src/TemplateManager/src/OutPerActionComplete/OutCreateComplete/functionYaml/template.ejs +33 -0
- package/src/TemplateManager/src/OutPerActionComplete/OutCreateComplete/handler/data.js +0 -0
- package/src/TemplateManager/src/OutPerActionComplete/OutCreateComplete/handler/template.ejs +0 -0
- package/src/TemplateManager/src/OutPerActionComplete/OutCreateComplete/mainFunction/createObjectComplete_main.js +172 -0
- package/src/TemplateManager/src/OutPerActionComplete/OutCreateComplete/mainFunction/data.js +0 -0
- package/src/TemplateManager/src/OutPerActionComplete/OutCreateComplete/mainFunction/template.ejs +0 -0
- package/src/TemplateManager/src/OutPerActionComplete/OutCreateComplete/sns-in-sqs/data.js +0 -0
- package/src/TemplateManager/src/OutPerActionComplete/OutCreateComplete/sns-in-sqs/template.ejs +0 -0
- package/src/TemplateManager/src/OutPerActionComplete/OutCreateComplete/sns-out/data.js +0 -0
- package/src/TemplateManager/src/OutPerActionComplete/OutCreateComplete/sns-out/template.ejs +0 -0
- package/src/TemplateManager/src/OutPerActionComplete/OutUpdateComplete/functionYaml/data.js +98 -0
- package/src/TemplateManager/src/OutPerActionComplete/OutUpdateComplete/functionYaml/template.ejs +33 -0
- package/src/TemplateManager/src/OutPerActionComplete/OutUpdateComplete/handler/data.js +59 -0
- package/src/TemplateManager/src/OutPerActionComplete/OutUpdateComplete/handler/template.ejs +129 -0
- package/src/TemplateManager/src/OutPerActionComplete/OutUpdateComplete/mainFunction/data.js +53 -0
- package/src/TemplateManager/src/OutPerActionComplete/OutUpdateComplete/mainFunction/template.ejs +126 -0
- package/src/TemplateManager/src/OutPerActionComplete/OutUpdateComplete/sns-out/data.js +62 -0
- package/src/TemplateManager/src/OutPerActionComplete/OutUpdateComplete/sqs-in-sns/data.js +58 -0
- package/src/TemplateManager/src/OutPerActionComplete/OutUpdateComplete/sqs-in-sns/template.ejs +47 -0
- package/src/TemplateManager/src/{FunctionYaml → PerActionEndpoint/FunctionYaml}/HdrApi/data.js +24 -20
- package/src/TemplateManager/src/{FunctionYaml → PerActionEndpoint/FunctionYaml}/HdrApi/template.ejs +2 -2
- package/src/TemplateManager/src/{FunctionYaml → PerActionEndpoint/FunctionYaml}/HdrDsq/data.js +27 -20
- package/src/TemplateManager/src/{FunctionYaml → PerActionEndpoint/FunctionYaml}/HdrInv/data.js +54 -22
- package/src/TemplateManager/src/{FunctionYaml → PerActionEndpoint/FunctionYaml}/HdrSqs/data.js +28 -23
- package/src/TemplateManager/src/PerActionEndpoint/FunctionYaml/HdrSqs/template.ejs +30 -0
- package/src/TemplateManager/src/PerActionEndpoint/Handler/HdrApi/data.js +6 -22
- package/src/TemplateManager/src/PerActionEndpoint/Handler/HdrApi/getTemplate.ejs +76 -0
- package/src/TemplateManager/src/PerActionEndpoint/Handler/HdrApi/updateTemplate.ejs +67 -0
- package/src/TemplateManager/src/PerActionEndpoint/Handler/HdrDsq/data.js +47 -37
- package/src/TemplateManager/src/PerActionEndpoint/Handler/HdrDsq/getTemplate.ejs +105 -0
- package/src/TemplateManager/src/PerActionEndpoint/Handler/HdrDsq/updateTemplate.ejs +109 -0
- package/src/TemplateManager/src/PerActionEndpoint/Handler/HdrInv/createTemplate.ejs +75 -0
- package/src/TemplateManager/src/PerActionEndpoint/Handler/HdrInv/data.js +68 -33
- package/src/TemplateManager/src/PerActionEndpoint/Handler/HdrInv/getTemplate.ejs +82 -0
- package/src/TemplateManager/src/PerActionEndpoint/Handler/HdrInv/updateTemplate.ejs +75 -0
- package/src/TemplateManager/src/PerActionEndpoint/Handler/HdrSqs/data.js +46 -30
- package/src/TemplateManager/src/PerActionEndpoint/Handler/HdrSqs/getTemplate.ejs +124 -0
- package/src/TemplateManager/src/PerActionEndpoint/Handler/HdrSqs/updateTemplate.ejs +133 -0
- package/src/TemplateManager/src/PerActionEndpoint/MainFunction/Create/CreateObject_main.js +760 -0
- package/src/TemplateManager/src/PerActionEndpoint/MainFunction/Create/data.js +67 -0
- package/src/TemplateManager/src/PerActionEndpoint/MainFunction/Create/request.json +0 -0
- package/src/TemplateManager/src/PerActionEndpoint/MainFunction/Create/template.ejs +581 -0
- package/src/TemplateManager/src/PerActionEndpoint/MainFunction/Get/data.js +0 -21
- package/src/TemplateManager/src/PerActionEndpoint/MainFunction/Get/template.ejs +34 -31
- package/src/TemplateManager/src/PerActionEndpoint/MainFunction/Get/testParam.json +5 -0
- package/src/TemplateManager/src/PerActionEndpoint/MainFunction/Update/data.js +61 -0
- package/src/TemplateManager/src/PerActionEndpoint/MainFunction/Update/request.json +0 -0
- package/src/TemplateManager/src/PerActionEndpoint/MainFunction/Update/template.ejs +267 -0
- package/src/TemplateManager/src/ProcessLogical/Handler/data.js +49 -0
- package/src/TemplateManager/src/ProcessLogical/Handler/template.ejs +129 -0
- package/src/TemplateManager/src/ProcessLogical/ProcessLogicalYaml/data.js +175 -0
- package/src/TemplateManager/src/ProcessLogical/ProcessLogicalYaml/template.ejs +25 -0
- package/src/TemplateManager/src/ProcessLogical/mainFunction/data.js +47 -0
- package/src/TemplateManager/src/ProcessLogical/mainFunction/template.ejs +421 -0
- package/src/TemplateManager/src/ProcessLogicalPagination/DsqYaml/data.js +50 -0
- package/src/TemplateManager/src/ProcessLogicalPagination/DsqYaml/template.ejs +32 -0
- package/src/TemplateManager/src/ProcessLogicalPagination/FunctionYaml/HdrDsq/data.js +167 -0
- package/src/TemplateManager/src/ProcessLogicalPagination/FunctionYaml/HdrDsq/template.ejs +25 -0
- package/src/TemplateManager/src/ProcessLogicalPagination/FunctionYaml/HdrSqs/data.js +169 -0
- package/src/TemplateManager/src/ProcessLogicalPagination/FunctionYaml/HdrSqs/template.ejs +25 -0
- package/src/TemplateManager/src/ProcessLogicalPagination/Handler/HdrDsq/data.js +48 -0
- package/src/TemplateManager/src/ProcessLogicalPagination/Handler/HdrDsq/template.ejs +163 -0
- package/src/TemplateManager/src/ProcessLogicalPagination/Handler/HdrSqs/data.js +48 -0
- package/src/TemplateManager/src/ProcessLogicalPagination/Handler/HdrSqs/template.ejs +146 -0
- package/src/TemplateManager/src/ProcessLogicalPagination/mainFunction/data.js +48 -0
- package/src/TemplateManager/src/ProcessLogicalPagination/mainFunction/template.ejs +212 -0
- package/src/TemplateManager/src/ResourceYaml/CreateSourceData.js +2 -2
- package/src/TemplateManager/src/ResourceYaml/dynamodb/awaitingMultipleStepData.js +5 -8
- package/src/TemplateManager/src/ResourceYaml/dynamodb/mainResourcePerObjectSchemaData.js +4 -26
- package/src/TemplateManager/src/ResourceYaml/dynamodb/processLogicalAndFindData.js +6 -10
- package/src/TemplateManager/src/ResourceYaml/sns-in-sqs/defaultSnsInSqsForFindDataAndProcessLogical.js +28 -16
- package/src/TemplateManager/src/ResourceYaml/sns-in-sqs/snsAndSqsPerActiondata.js +5 -5
- package/src/TemplateManager/src/ResourceYaml/sns-out/data.js +3 -3
- package/src/TemplateManager/src/ResourceYaml/sns-out/defaultSnsOutForFindDataAndProcessLogical.js +75 -0
- package/src/TemplateManager/src/TranslateIdReq/ProcessingTranslateIds/functionYaml/data.js +95 -0
- package/src/TemplateManager/src/{FunctionYaml/HdrSqs → TranslateIdReq/ProcessingTranslateIds/functionYaml}/template.ejs +1 -1
- package/src/TemplateManager/src/TranslateIdReq/ProcessingTranslateIds/handler/dataHdrDsq.js +52 -0
- package/src/TemplateManager/src/TranslateIdReq/ProcessingTranslateIds/handler/template.ejs +194 -0
- package/src/TemplateManager/src/TranslateIdReq/ProcessingTranslateIds/mainFunction/data.js +48 -0
- package/src/TemplateManager/src/TranslateIdReq/ProcessingTranslateIds/mainFunction/template.ejs +330 -0
- package/src/TemplateManager/src/TranslateIdReq/ProcessingTranslateIds/sns-out/data.js +47 -0
- package/src/TemplateManager/src/TranslateIdReq/ProcessingTranslateIds/sqs-sns/data.js +58 -0
- package/src/TemplateManager/src/TranslateIdReq/ProcessingTranslateIds/sqs-sns/template.ejs +43 -0
- package/src/TemplateManager/src/TranslateIdReq/TranslateIds/functionYaml/HdrDsq/data.js +116 -0
- package/src/TemplateManager/src/TranslateIdReq/TranslateIds/functionYaml/HdrSqs/data.js +116 -0
- package/src/TemplateManager/src/TranslateIdReq/TranslateIds/handler/HdrDsq/data.js +60 -0
- package/src/TemplateManager/src/TranslateIdReq/TranslateIds/handler/HdrDsq/template.ejs +157 -0
- package/src/TemplateManager/src/TranslateIdReq/TranslateIds/handler/HdrSqs/data.js +59 -0
- package/src/TemplateManager/src/TranslateIdReq/TranslateIds/handler/HdrSqs/template.ejs +175 -0
- package/src/TemplateManager/src/TranslateIdReq/TranslateIds/mainFunction/data.js +61 -0
- package/src/TemplateManager/src/TranslateIdReq/TranslateIds/mainFunction/template.ejs +155 -0
- package/src/TemplateManager/src/TranslateIdReq/TranslateIds/resourceYaml/dynamoDb/data.js +120 -0
- package/src/TemplateManager/src/TranslateIdReq/TranslateIds/resourceYaml/sns-sqs/data.js +75 -0
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRalationshipComplete/functionYaml/data.js +8 -24
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRalationshipComplete/handler/HdrSqs/data.js +7 -21
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRalationshipComplete/mainFunction/data.js +4 -3
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRalationshipComplete/mainFunction/template.ejs +1 -1
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRalationshipComplete/sns-in-sqs/data.js +10 -13
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRalationshipComplete/sns-in-sqs/template.ejs +1 -0
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRalationshipComplete/sns-out/data.js +6 -5
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/functionYaml/HdrApi/data.js +13 -21
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/functionYaml/HdrDsq/data.js +11 -29
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/functionYaml/HdrInv/data.js +16 -21
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/functionYaml/HdrSqs/data.js +12 -27
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/mainFunction/data.js +3 -18
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/mainFunction/template.ejs +18 -11
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/perAction/HdrApi/data.js +5 -18
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/perAction/HdrDsq/data.js +5 -19
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/perAction/HdrInv/data.js +7 -18
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/perAction/HdrSqs/data.js +6 -20
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/perAction/request.json +3 -4
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/sns-in-sqs/data.js +5 -6
- package/src/TemplateManager/src/UpdateRelationshipSchema/updateRelationship/sns-out/data.js +4 -4
- package/src/TemplateManager/src/externalService/LambdaRole/data.js +181 -59
- package/src/TemplateManager/src/externalService/LambdaRole/template.ejs +17 -15
- package/src/TemplateManager/src/externalService/SnsTopicSubscriotions/data.js +56 -44
- package/src/TemplateManager/src/externalService/SnsTopicSubscriotions/template.ejs +3 -4
- package/src/TemplateManager/src/libs/Consts.js +162 -13
- package/src/TemplateManager/src/PerActionEndpoint/Handler/testRequest.json +0 -5
- /package/src/TemplateManager/src/{FunctionYaml → PerActionEndpoint/FunctionYaml}/HdrApi/request.json +0 -0
- /package/src/TemplateManager/src/{FunctionYaml → PerActionEndpoint/FunctionYaml}/HdrDsq/request.json +0 -0
- /package/src/TemplateManager/src/{FunctionYaml → PerActionEndpoint/FunctionYaml}/HdrDsq/template.ejs +0 -0
- /package/src/TemplateManager/src/{FunctionYaml → PerActionEndpoint/FunctionYaml}/HdrInv/example req.js +0 -0
- /package/src/TemplateManager/src/{FunctionYaml → PerActionEndpoint/FunctionYaml}/HdrInv/request.json +0 -0
- /package/src/TemplateManager/src/{FunctionYaml → PerActionEndpoint/FunctionYaml}/HdrInv/template.ejs +0 -0
- /package/src/TemplateManager/src/{FunctionYaml → PerActionEndpoint/FunctionYaml}/HdrSqs/request.json +0 -0
|
@@ -0,0 +1,279 @@
|
|
|
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
|
+
|
|
20
|
+
const path = require('path');
|
|
21
|
+
|
|
22
|
+
const { SOURCE_PATH, FUNCTION_NAME } = require("../../libs/Consts");
|
|
23
|
+
const { firstLetterUpperCase: upperCase } = require("../../../../MainLibs/src/Utils")
|
|
24
|
+
|
|
25
|
+
const serviceSchemas = require('@izara_project/izara-core-library-service-schemas');
|
|
26
|
+
const STORAGE_TYPES = serviceSchemas.consts.STORAGE_TYPES;
|
|
27
|
+
const getObjectSchemas = serviceSchemas.getObjectSchema;
|
|
28
|
+
const { getUsedFieldNamesOfIdentifiers } = serviceSchemas.utils;
|
|
29
|
+
|
|
30
|
+
const templatePath = path.join(__dirname, "./template.ejs")
|
|
31
|
+
const getByDynamoTemplate = path.join(__dirname, "../GetByStorage/getByDynamo.ejs")
|
|
32
|
+
const getByGraphTemplate = path.join(__dirname, "../GetByStorage/getByGraph.ejs")
|
|
33
|
+
|
|
34
|
+
const NoRetryError = require("@izara_project/izara-core-library-core/src/NoRetryError");
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* receive objectSchema
|
|
38
|
+
* create data for FindDataMain template
|
|
39
|
+
*
|
|
40
|
+
* @param {Object} objectSchema
|
|
41
|
+
* @return {{ templatePath, templateData, setting } }
|
|
42
|
+
*/
|
|
43
|
+
|
|
44
|
+
async function data(_izContext, srcPath) {
|
|
45
|
+
|
|
46
|
+
let datas = [];
|
|
47
|
+
|
|
48
|
+
// 1. get objectTypes for check objType param
|
|
49
|
+
let getObjectTypes = await getObjectSchemas.getAllLocalObjectSchemas(_izContext, srcPath);
|
|
50
|
+
// console.log(("getObjectTypes: ", getObjectTypes.fieldLookup)
|
|
51
|
+
|
|
52
|
+
for (const objectType of Object.keys(getObjectTypes.fieldLookup)) {
|
|
53
|
+
// console.log(("objectType: ", objectType)
|
|
54
|
+
|
|
55
|
+
// 2. get local object schema
|
|
56
|
+
let objectSchemaRecord = await getObjectSchemas.getLocalObjectSchemasWithHierarchy(
|
|
57
|
+
_izContext,
|
|
58
|
+
objectType,
|
|
59
|
+
srcPath
|
|
60
|
+
);
|
|
61
|
+
// console.log(("objectSchemaRecord: ", objectSchemaRecord)
|
|
62
|
+
|
|
63
|
+
let objectSchema = objectSchemaRecord.records[0];
|
|
64
|
+
// console.log(("objectSchema: ", objectSchema)
|
|
65
|
+
|
|
66
|
+
const identifiersNames = getUsedFieldNamesOfIdentifiers(_izContext, objectSchema.identifiers);
|
|
67
|
+
_izContext.logger.debug("identifiersNames: ", identifiersNames);
|
|
68
|
+
|
|
69
|
+
let storageResources = objectSchema.storageResources;
|
|
70
|
+
let fieldNames = objectSchema.fieldNames; // object
|
|
71
|
+
let fieldNameDatas = [];
|
|
72
|
+
|
|
73
|
+
// loop for each main fieldNames
|
|
74
|
+
Object.entries(fieldNames).map(([field, schemas]) => {
|
|
75
|
+
// console.log(("field: ", field)
|
|
76
|
+
// console.log(("schemas: ", schemas)
|
|
77
|
+
|
|
78
|
+
let getInIdentifiers = false;
|
|
79
|
+
|
|
80
|
+
for (const identifierName of identifiersNames) {
|
|
81
|
+
if (field === identifierName) {
|
|
82
|
+
getInIdentifiers = true;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
//* set field as key of object
|
|
87
|
+
//* use schemas for find storageType, graphServiceTag, tableName
|
|
88
|
+
|
|
89
|
+
// check type (use only string and number)
|
|
90
|
+
if (schemas.type === "string" || schemas.type === "number") {
|
|
91
|
+
|
|
92
|
+
let collectStorageDetail = {};
|
|
93
|
+
let storageResourceTags = schemas.storageResourceTags; // array
|
|
94
|
+
|
|
95
|
+
for (const storageResourceTag of storageResourceTags) {
|
|
96
|
+
// console.log(("storageResources: ", storageResources)
|
|
97
|
+
|
|
98
|
+
Object.entries(storageResources).map(([storageTag, storageDetail]) => {
|
|
99
|
+
|
|
100
|
+
if (storageResourceTag === storageTag) {
|
|
101
|
+
// console.log(("storageTag: ", storageTag)
|
|
102
|
+
// console.log(("storageDetail: ", storageDetail)
|
|
103
|
+
|
|
104
|
+
if (storageDetail.storageType === STORAGE_TYPES.graph) {
|
|
105
|
+
|
|
106
|
+
if (collectStorageDetail.hasOwnProperty(STORAGE_TYPES.graph)) {
|
|
107
|
+
// console.log(("collectStorageDetail already have graph storageType")
|
|
108
|
+
} else {
|
|
109
|
+
Object.assign(collectStorageDetail,
|
|
110
|
+
{
|
|
111
|
+
[storageDetail.storageType]: {
|
|
112
|
+
graphServerTag: storageDetail.graphServerTag,
|
|
113
|
+
getInIdentifiers: getInIdentifiers
|
|
114
|
+
}
|
|
115
|
+
})
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
} else if (storageDetail.storageType === STORAGE_TYPES.dynamoDB) {
|
|
119
|
+
|
|
120
|
+
if (collectStorageDetail.hasOwnProperty(STORAGE_TYPES.dynamoDB)) {
|
|
121
|
+
// console.log(("collectStorageDetail already have dynamoDB storageType")
|
|
122
|
+
} else {
|
|
123
|
+
Object.assign(collectStorageDetail,
|
|
124
|
+
{
|
|
125
|
+
[storageDetail.storageType]: {
|
|
126
|
+
tableName: storageDetail.tableName
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
)
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
})
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
// console.log(("collectStorageDetail: ", collectStorageDetail)
|
|
137
|
+
|
|
138
|
+
//* Q: chooooooose get data from dynamoDB or graph if this fieldName have both of dynamoDB and graph storageTypes ???
|
|
139
|
+
//* A: choose dynamoDB
|
|
140
|
+
// collectStorageDetail: {
|
|
141
|
+
// graph: { graphServerTag: 'GraphHandler' },
|
|
142
|
+
// dynamoDB: { tableName: 'NotificationHello' }
|
|
143
|
+
// }
|
|
144
|
+
if (collectStorageDetail.hasOwnProperty(STORAGE_TYPES.graph) && collectStorageDetail.hasOwnProperty(STORAGE_TYPES.dynamoDB)) {
|
|
145
|
+
delete collectStorageDetail[STORAGE_TYPES.graph];
|
|
146
|
+
// console.log(("collectStorageDetail after delete graph: ", collectStorageDetail)
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
fieldNameDatas.push({ [field]: collectStorageDetail })
|
|
150
|
+
// console.log(("fieldNameDatasMain: ", fieldNameDatas)
|
|
151
|
+
}
|
|
152
|
+
})
|
|
153
|
+
|
|
154
|
+
// fieldName in versionedData
|
|
155
|
+
if (objectSchema.hasOwnProperty("addOnDataStructure")) { // array
|
|
156
|
+
// console.log(("objectSchemas have addOnDataStructure: ", objectSchema.addOnDataStructure)
|
|
157
|
+
|
|
158
|
+
for (const versionedData of objectSchema.addOnDataStructure) { // object // loop versionedData
|
|
159
|
+
// console.log("versionedData: ", versionedData)
|
|
160
|
+
|
|
161
|
+
let versionedStorageDetail = {};
|
|
162
|
+
let versioendStorageResourceTag = versionedData.storageResourceTag;
|
|
163
|
+
let versionedFieldNames = versionedData.fieldNames; // array
|
|
164
|
+
|
|
165
|
+
Object.entries(storageResources).map(([storageTag, storageDetail]) => {
|
|
166
|
+
|
|
167
|
+
if (versioendStorageResourceTag === storageTag) {
|
|
168
|
+
if (storageDetail.storageType === STORAGE_TYPES.graph) {
|
|
169
|
+
versionedStorageDetail = {
|
|
170
|
+
[storageDetail.storageType]: {
|
|
171
|
+
graphServerTag: storageDetail.graphServerTag,
|
|
172
|
+
versionedDataLabel: versionedData.versionedDataLabel
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
} else {
|
|
176
|
+
throw new NoRetryError(`storageType of versionedData isn't graph`)
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
})
|
|
180
|
+
// console.log(("versionedStorageDetail: ", versionedStorageDetail)
|
|
181
|
+
|
|
182
|
+
for (const versionedFieldName of versionedFieldNames) { // object // loop versionedFieldNames
|
|
183
|
+
|
|
184
|
+
if (versionedFieldName.type === "string" || versionedFieldName.type === "number") {
|
|
185
|
+
fieldNameDatas.push({ [versionedFieldName.fieldName]: versionedStorageDetail })
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
} // end loop versionedFieldNames
|
|
189
|
+
|
|
190
|
+
} // end loop versionedData
|
|
191
|
+
//fieldNameDatas.push(collectVersionedFieldNames)
|
|
192
|
+
|
|
193
|
+
}
|
|
194
|
+
// console.log(("fieldNameDatas: ", fieldNameDatas)
|
|
195
|
+
|
|
196
|
+
let fieldNameDatasPerObjectType = {
|
|
197
|
+
objectType: objectType,
|
|
198
|
+
fieldNames: fieldNameDatas
|
|
199
|
+
};
|
|
200
|
+
// console.log(("fieldNameDatasPerObjectType: ", fieldNameDatasPerObjectType)
|
|
201
|
+
|
|
202
|
+
datas.push(fieldNameDatasPerObjectType)
|
|
203
|
+
} // end loop objectType
|
|
204
|
+
|
|
205
|
+
// console.log(("datas: ", datas)
|
|
206
|
+
|
|
207
|
+
// fieldNameDatas: [
|
|
208
|
+
// { notificationId: { graph: [Object], dynamoDB: [Object] } },
|
|
209
|
+
// { notificationIdHello: { dynamoDB: {tableName: "NotificationHello"}} },
|
|
210
|
+
// { notificationName: { graph: {graphServerTag: 'GraphHandler', versionedDataLabel: 'notificationSettings' }},
|
|
211
|
+
// { notificationNameeeeeeeeeee: { graph: {graphServerTag: 'GraphHandler', versionedDataLabel: 'notificationSettingssssssssss'}}
|
|
212
|
+
// ]
|
|
213
|
+
|
|
214
|
+
// fieldNameDatasPerObjectType: {
|
|
215
|
+
// objectType: 'notification',
|
|
216
|
+
// fieldNames: [
|
|
217
|
+
// { notificationId: [Object] },
|
|
218
|
+
// { notificationIdHello: [Object] },
|
|
219
|
+
// { notificationName: [Object]},
|
|
220
|
+
// { notificationNameeeeeeeeeee: [Object] }
|
|
221
|
+
// ]
|
|
222
|
+
// }
|
|
223
|
+
|
|
224
|
+
return {
|
|
225
|
+
templatePath: templatePath,
|
|
226
|
+
templateData: {
|
|
227
|
+
functionName: upperCase(FUNCTION_NAME.findData),
|
|
228
|
+
datas: datas,
|
|
229
|
+
getByDynamoTemplate: getByDynamoTemplate,
|
|
230
|
+
getByGraphTemplate: getByGraphTemplate,
|
|
231
|
+
storageDynamo: STORAGE_TYPES.dynamoDB,
|
|
232
|
+
storageTypeGraph: STORAGE_TYPES.graph,
|
|
233
|
+
},
|
|
234
|
+
setting: {
|
|
235
|
+
savePath: path.join(srcPath, SOURCE_PATH.findData),
|
|
236
|
+
saveFileName: `FindData_Main`,
|
|
237
|
+
fileExtension: '.js',
|
|
238
|
+
isAppend: false
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
// datas: [
|
|
243
|
+
// {
|
|
244
|
+
// objectType: 'consolidated',
|
|
245
|
+
// fieldNames: [ {notificationGroupId: [Object], time: [Object]}]
|
|
246
|
+
// },
|
|
247
|
+
// {
|
|
248
|
+
// objectType: 'notificationGroup',
|
|
249
|
+
// fieldNames: [
|
|
250
|
+
// {notificationGroupId: [Object]},
|
|
251
|
+
// {notificationGroupName: [Object]},
|
|
252
|
+
// {consolidatedType: [Object]},
|
|
253
|
+
// {consolidatedFrequency: [Object]},
|
|
254
|
+
// {consolidatedNextSendDue: [Object]}
|
|
255
|
+
// ]
|
|
256
|
+
// },
|
|
257
|
+
// {
|
|
258
|
+
// objectType: 'notification',
|
|
259
|
+
// fieldNames: [
|
|
260
|
+
// {notificationId: [Object]},
|
|
261
|
+
// {notificationIdHello: [Object]},
|
|
262
|
+
// {notificationName: [Object]},
|
|
263
|
+
// {notificationNameeeeeeeeeee: [Object]}
|
|
264
|
+
// ]
|
|
265
|
+
// },
|
|
266
|
+
// {
|
|
267
|
+
// objectType: 'notificationTrigger',
|
|
268
|
+
// fieldNames: [
|
|
269
|
+
// {notificationTriggerId: [Object]},
|
|
270
|
+
// {propertyName: [Object]},
|
|
271
|
+
// {valueType: [Object]},
|
|
272
|
+
// {valueString: [Object]},
|
|
273
|
+
// {valueNumber: [Object]}
|
|
274
|
+
// ]
|
|
275
|
+
// }
|
|
276
|
+
// ]
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
module.exports = data;
|
|
@@ -0,0 +1,155 @@
|
|
|
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
|
+
|
|
20
|
+
const izaraShared = require("@izara_project/izara-shared");
|
|
21
|
+
const findDataSharedLib = izaraShared.findDataSharedLib;
|
|
22
|
+
const graphSharedLib = izaraShared.graphSharedLib;
|
|
23
|
+
const dynamodbSharedLib = izaraShared.dynamodbSharedLib;
|
|
24
|
+
|
|
25
|
+
const serviceSchemas = require('@izara_project/izara-core-library-service-schemas');
|
|
26
|
+
const serviceConfig = serviceSchemas.serviceConfig;
|
|
27
|
+
const identifierObj = serviceSchemas.identifiersObject
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* triggered from searchResult for each requiredData field per one identifiers
|
|
31
|
+
* @param {Object} _izContext
|
|
32
|
+
* @param {string} fieldName
|
|
33
|
+
* @param {Object} objType
|
|
34
|
+
* @param {Object} identifiers
|
|
35
|
+
* @param {Object} requestProperties
|
|
36
|
+
*
|
|
37
|
+
* @returns {object} description of return value
|
|
38
|
+
*/
|
|
39
|
+
|
|
40
|
+
exports.findData = async (
|
|
41
|
+
_izContext,
|
|
42
|
+
fieldName,
|
|
43
|
+
objType,
|
|
44
|
+
identifiers,
|
|
45
|
+
requestProperties,
|
|
46
|
+
callingFlow,
|
|
47
|
+
//(<additionalParams>)
|
|
48
|
+
//(</additionalParams>)
|
|
49
|
+
) => {
|
|
50
|
+
|
|
51
|
+
try {
|
|
52
|
+
|
|
53
|
+
_izContext.logger.debug('----- findData event params -----', {
|
|
54
|
+
fieldName: fieldName,
|
|
55
|
+
objType: objType,
|
|
56
|
+
identifiers: identifiers,
|
|
57
|
+
requestProperties: requestProperties,
|
|
58
|
+
callingFlow: callingFlow
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
// removeAttributes on expired
|
|
62
|
+
let removeAttributes = [];
|
|
63
|
+
//(<removeAttributes>)
|
|
64
|
+
//(</removeAttributes>)
|
|
65
|
+
|
|
66
|
+
// Check/create FindDataMain status
|
|
67
|
+
let [findDataMainStatus, findDataId, findDataMain] = await findDataSharedLib.checkFindDataMainStatus(
|
|
68
|
+
_izContext,
|
|
69
|
+
fieldName,
|
|
70
|
+
objType,
|
|
71
|
+
identifiers,
|
|
72
|
+
requestProperties,
|
|
73
|
+
callingFlow,
|
|
74
|
+
removeAttributes
|
|
75
|
+
);
|
|
76
|
+
_izContext.logger.debug("result after checkFindDataMainStatus is", {
|
|
77
|
+
findDataMainStatus: findDataMainStatus,
|
|
78
|
+
findDataId: findDataId,
|
|
79
|
+
findDataMain: findDataMain
|
|
80
|
+
})
|
|
81
|
+
|
|
82
|
+
if (findDataMainStatus != "process") {
|
|
83
|
+
_izContext.logger.debug(`findDataMainStatus status isn't process :${findDataMainStatus}`)
|
|
84
|
+
return; // stop process
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
let identifiersObject = await identifierObj.concatIdentifiersObjectFromIdentifiersObject(
|
|
88
|
+
_izContext,
|
|
89
|
+
objType,
|
|
90
|
+
identifiers
|
|
91
|
+
);
|
|
92
|
+
_izContext.logger.debug("create identifiersObject from identifiers: ", identifiersObject) // object
|
|
93
|
+
|
|
94
|
+
let errorsFound = [];
|
|
95
|
+
|
|
96
|
+
let standardErrorParams = [
|
|
97
|
+
_izContext,
|
|
98
|
+
fieldName,
|
|
99
|
+
objType,
|
|
100
|
+
identifiers,
|
|
101
|
+
requestProperties,
|
|
102
|
+
null,
|
|
103
|
+
"error"
|
|
104
|
+
];
|
|
105
|
+
|
|
106
|
+
<% for (let idx = 0; idx < datas.length; idx++) { _%>
|
|
107
|
+
<% let objectType = datas[idx].objectType _%>
|
|
108
|
+
if (objType.objectType === <%- JSON.stringify(objectType) %>) {
|
|
109
|
+
_izContext.logger.debug("objectType: ", objType.objectType)
|
|
110
|
+
|
|
111
|
+
<% let fieldNames = datas[idx].fieldNames _%>
|
|
112
|
+
<% for (let idx = 0; idx < fieldNames.length; idx++) { _%>
|
|
113
|
+
<% let fieldName = Object.keys(fieldNames[idx])[0] _%>
|
|
114
|
+
<% let storageDetails = (Object.values(fieldNames[idx])[0]) _%>
|
|
115
|
+
if (fieldName == <%- JSON.stringify(fieldName) %>) {
|
|
116
|
+
_izContext.logger.debug("fieldName: ", fieldName)
|
|
117
|
+
|
|
118
|
+
<% Object.entries(storageDetails).map(([storage, details]) => { _%>
|
|
119
|
+
<% let versionedDataLabel = [] _%>
|
|
120
|
+
<% if (storage === storageTypeGraph && details.hasOwnProperty("versionedDataLabel")){ versionedDataLabel.push(details.versionedDataLabel) } _%>
|
|
121
|
+
<% if (storage === storageDynamo){ %><%- include(getByDynamoTemplate, {tableName: details.tableName, fieldName: fieldName, objectType: objectType}) %><% } _%>
|
|
122
|
+
<% if (storage === storageTypeGraph){ %><%- include(getByGraphTemplate, {graphServerTag: details.graphServerTag, versionedDataLabel: versionedDataLabel, fieldName: fieldName, objectType: objectType, getInIdentifiers: details.getInIdentifiers}) %><% } _%>
|
|
123
|
+
<% }) _%>
|
|
124
|
+
}<% if (idx + 1 == fieldNames.length) { %>
|
|
125
|
+
<%- createAdditionalFieldNamesTag(objectType) %>
|
|
126
|
+
<% } _%>
|
|
127
|
+
else <% } _%> {
|
|
128
|
+
errorsFound.push("unrecognised fieldName")
|
|
129
|
+
standardErrorParams.push(errorsFound)
|
|
130
|
+
await findDataSharedLib.completeFindDataMain(...standardErrorParams);
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
} <% if (idx + 1 == datas.length) { %>
|
|
134
|
+
//(<addtionalObjectType>)
|
|
135
|
+
//(</addtionalObjectType>)
|
|
136
|
+
<% } _%>
|
|
137
|
+
else<% } %> {
|
|
138
|
+
errorsFound.push("unrecognised objectType")
|
|
139
|
+
standardErrorParams.push(errorsFound)
|
|
140
|
+
await findDataSharedLib.completeFindDataMain(...standardErrorParams);
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
return "Function FindData Finish";
|
|
145
|
+
|
|
146
|
+
} catch (err) {
|
|
147
|
+
_izContext.logger.error('error FindDataMain: ', err)
|
|
148
|
+
throw (err)
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
<%_ function createAdditionalFieldNamesTag(objectType) {
|
|
153
|
+
return `//(<additional${objectType}FieldNames>)
|
|
154
|
+
//(</additional${objectType}FieldNames>)`
|
|
155
|
+
} _%>
|
|
@@ -81,7 +81,7 @@ async function generateCodeWithTemplate(_izContext, objSchemaPath) {
|
|
|
81
81
|
|
|
82
82
|
// create main resource per relationshipSchema
|
|
83
83
|
const createSourceMainResourcesRelSchema = mainResources.createSourceDataRelSchema(_izContext, { [relTag]: relTagData }, saveFilePath);
|
|
84
|
-
console.log("createSourceMainResourcesRelSchema: ", createSourceMainResourcesRelSchema);
|
|
84
|
+
// console.log("createSourceMainResourcesRelSchema: ", createSourceMainResourcesRelSchema);
|
|
85
85
|
|
|
86
86
|
createSourceParams = createSourceParams.concat(createSourceMainResourcesRelSchema);
|
|
87
87
|
}
|