@izara_project/izara-market-library-service-schemas 1.0.65 → 1.0.67
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 +3 -3
- package/src/GenerateCodeLibs/src/Consts.js +7 -2
- package/src/GenerateCodeLibs/src/GenerateCodeLibs.js +11 -1
- package/src/MainLibs/src/Consts.js +64 -25
- package/src/MainLibs/src/GenerateCodeUtils.js +6 -6
- package/src/reStructure/GenerateCode.js +2 -1
- package/src/reStructure/TemplateData/EndpointPerService/generateTemplateData.js +1 -1
- package/src/reStructure/TemplateData/EndpointPerService/mainFunction/create/template.ejs +20 -4
- package/src/reStructure/TemplateData/EndpointPerService/yaml/data.js +49 -5
- package/src/reStructure/TemplateData/externalService/snsTopicSubscriptions/data.js +3 -0
- package/src/reStructure/TemplateData/findData/findDataYaml/data.js +2 -2
- package/src/reStructure/TemplateData/flowSchema/components/upload/createObjectComplete/functionYaml/data.js +1 -1
- package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/reservedLimit/mainFunction/data.js +3 -1
- package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/reservedLimit/mainFunction/template.ejs +14 -0
- package/src/reStructure/TemplateData/flowSchema/dynamoDb/data.js +2 -2
- package/src/reStructure/TemplateData/flowSchema/flowStep/functionYaml/data.js +3 -3
- package/src/reStructure/TemplateData/flowSchema/flowStep/handler/data.js +1 -1
- package/src/reStructure/TemplateData/flowSchema/flowStep/sns-in/data.js +4 -2
- package/src/reStructure/TemplateData/flowSchema/flowStep/sns-in/template.ejs +9 -9
- package/src/reStructure/TemplateData/flowSchema/generateTemplateData.js +24 -24
- package/src/reStructure/TemplateData/generateRole/data.js +38 -24
- package/src/reStructure/TemplateData/generateRole/template.ejs +5 -7
- package/src/reStructure/TemplateData/perActionComplete/create/yaml/data.js +1 -1
- package/src/reStructure/TemplateData/perActionComplete/delete/yaml/data.js +1 -1
- package/src/reStructure/TemplateData/perActionComplete/get/yaml/data.js +1 -1
- package/src/reStructure/TemplateData/perActionComplete/update/yaml/data.js +1 -1
- package/src/reStructure/TemplateData/processLogical/yaml/data.js +4 -4
- package/src/reStructure/TemplateData/processLogicalPagination/yaml/dsq/data.js +2 -2
- package/src/reStructure/TemplateData/processLogicalPagination/yaml/sqs/data.js +2 -2
- package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/functionYaml/api/data.js +1 -1
- package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/functionYaml/data.js +136 -0
- package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/functionYaml/dsq/data.js +1 -1
- package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/functionYaml/inv/data.js +1 -1
- package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/functionYaml/sqs/data.js +1 -1
- package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/functionYaml/template.ejs +9 -0
- package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/functionYaml/templateByHandler/apiTemplate.ejs +20 -0
- package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/functionYaml/templateByHandler/dsqTemplate.ejs +17 -0
- package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/functionYaml/templateByHandler/invTemplate.ejs +13 -0
- package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/functionYaml/templateByHandler/sqsTemplate.ejs +17 -0
- package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/handler/data.js +73 -0
- package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/handler/template.ejs +9 -0
- package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/handler/templateByHandler/apiTemplate.ejs +155 -0
- package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/handler/templateByHandler/dsqTemplate.ejs +202 -0
- package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/handler/templateByHandler/invTemplate.ejs +144 -0
- package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/handler/templateByHandler/sqsTemplate.ejs +181 -0
- package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/mainFunction/template.ejs +11 -11
- package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/complete/functionYaml/data.js +1 -1
- package/src/reStructure/TemplateData/relationshipPerAction/create/action/functionYaml/api/data.js +1 -1
- package/src/reStructure/TemplateData/relationshipPerAction/create/action/functionYaml/data.js +159 -0
- package/src/reStructure/TemplateData/relationshipPerAction/create/action/functionYaml/dsq/data.js +2 -2
- package/src/reStructure/TemplateData/relationshipPerAction/create/action/functionYaml/inv/data.js +2 -2
- package/src/reStructure/TemplateData/relationshipPerAction/create/action/functionYaml/sqs/data.js +2 -2
- package/src/reStructure/TemplateData/relationshipPerAction/create/action/functionYaml/template.ejs +9 -0
- package/src/reStructure/TemplateData/relationshipPerAction/create/action/functionYaml/templateByHandler/apiTemplate.ejs +20 -0
- package/src/reStructure/TemplateData/relationshipPerAction/create/action/functionYaml/templateByHandler/dsqTemplate.ejs +17 -0
- package/src/reStructure/TemplateData/relationshipPerAction/create/action/functionYaml/templateByHandler/invTemplate.ejs +13 -0
- package/src/reStructure/TemplateData/relationshipPerAction/create/action/functionYaml/templateByHandler/sqsTemplate.ejs +17 -0
- package/src/reStructure/TemplateData/relationshipPerAction/create/action/handler/data.js +73 -0
- package/src/reStructure/TemplateData/relationshipPerAction/create/action/handler/template.ejs +9 -0
- package/src/reStructure/TemplateData/relationshipPerAction/create/action/handler/templateByHandler/apiTemplate.ejs +155 -0
- package/src/reStructure/TemplateData/relationshipPerAction/create/action/handler/templateByHandler/dsqTemplate.ejs +202 -0
- package/src/reStructure/TemplateData/relationshipPerAction/create/action/handler/templateByHandler/invTemplate.ejs +144 -0
- package/src/reStructure/TemplateData/relationshipPerAction/create/action/handler/templateByHandler/sqsTemplate.ejs +181 -0
- package/src/reStructure/TemplateData/relationshipPerAction/create/complete/functionYaml/data.js +1 -1
- package/src/reStructure/TemplateData/relationshipPerAction/delete/action/functionYaml/api/data.js +1 -1
- package/src/reStructure/TemplateData/relationshipPerAction/delete/action/functionYaml/data.js +158 -0
- package/src/reStructure/TemplateData/relationshipPerAction/delete/action/functionYaml/dsq/data.js +2 -2
- package/src/reStructure/TemplateData/relationshipPerAction/delete/action/functionYaml/inv/data.js +2 -2
- package/src/reStructure/TemplateData/relationshipPerAction/delete/action/functionYaml/sqs/data.js +1 -1
- package/src/reStructure/TemplateData/relationshipPerAction/delete/action/functionYaml/template.ejs +9 -0
- package/src/reStructure/TemplateData/relationshipPerAction/delete/action/functionYaml/templateByHandler/apiTemplate.ejs +20 -0
- package/src/reStructure/TemplateData/relationshipPerAction/delete/action/functionYaml/templateByHandler/dsqTemplate.ejs +17 -0
- package/src/reStructure/TemplateData/relationshipPerAction/delete/action/functionYaml/templateByHandler/invTemplate.ejs +13 -0
- package/src/reStructure/TemplateData/relationshipPerAction/delete/action/functionYaml/templateByHandler/sqsTemplate.ejs +17 -0
- package/src/reStructure/TemplateData/relationshipPerAction/delete/action/handler/data.js +73 -0
- package/src/reStructure/TemplateData/relationshipPerAction/delete/action/handler/template.ejs +9 -0
- package/src/reStructure/TemplateData/relationshipPerAction/delete/action/handler/templateByHandler/apiTemplate.ejs +155 -0
- package/src/reStructure/TemplateData/relationshipPerAction/delete/action/handler/templateByHandler/dsqTemplate.ejs +202 -0
- package/src/reStructure/TemplateData/relationshipPerAction/delete/action/handler/templateByHandler/invTemplate.ejs +144 -0
- package/src/reStructure/TemplateData/relationshipPerAction/delete/action/handler/templateByHandler/sqsTemplate.ejs +181 -0
- package/src/reStructure/TemplateData/relationshipPerAction/delete/complete/functionYaml/data.js +1 -1
- package/src/reStructure/TemplateData/relationshipPerAction/generateTemplateData.js +131 -88
- package/src/reStructure/TemplateData/relationshipPerAction/get/action/functionYaml/api/data.js +2 -2
- package/src/reStructure/TemplateData/relationshipPerAction/get/action/functionYaml/data.js +158 -0
- package/src/reStructure/TemplateData/relationshipPerAction/get/action/functionYaml/dsq/data.js +2 -2
- package/src/reStructure/TemplateData/relationshipPerAction/get/action/functionYaml/inv/data.js +2 -2
- package/src/reStructure/TemplateData/relationshipPerAction/get/action/functionYaml/sqs/data.js +1 -1
- package/src/reStructure/TemplateData/relationshipPerAction/get/action/functionYaml/template.ejs +9 -0
- package/src/reStructure/TemplateData/relationshipPerAction/get/action/functionYaml/templateByHandler/apiTemplate.ejs +20 -0
- package/src/reStructure/TemplateData/relationshipPerAction/get/action/functionYaml/templateByHandler/dsqTemplate.ejs +17 -0
- package/src/reStructure/TemplateData/relationshipPerAction/get/action/functionYaml/templateByHandler/invTemplate.ejs +13 -0
- package/src/reStructure/TemplateData/relationshipPerAction/get/action/functionYaml/templateByHandler/sqsTemplate.ejs +17 -0
- package/src/reStructure/TemplateData/relationshipPerAction/get/action/handler/data.js +73 -0
- package/src/reStructure/TemplateData/relationshipPerAction/get/action/handler/template.ejs +9 -0
- package/src/reStructure/TemplateData/relationshipPerAction/get/action/handler/templateByHandler/apiTemplate.ejs +155 -0
- package/src/reStructure/TemplateData/relationshipPerAction/get/action/handler/templateByHandler/dsqTemplate.ejs +202 -0
- package/src/reStructure/TemplateData/relationshipPerAction/get/action/handler/templateByHandler/invTemplate.ejs +144 -0
- package/src/reStructure/TemplateData/relationshipPerAction/get/action/handler/templateByHandler/sqsTemplate.ejs +181 -0
- package/src/reStructure/TemplateData/relationshipPerAction/get/complete/functionYaml/data.js +1 -1
- package/src/reStructure/TemplateData/relationshipPerAction/moveRelationship/action/functionYaml/data.js +160 -0
- package/src/reStructure/TemplateData/relationshipPerAction/moveRelationship/action/functionYaml/template.ejs +9 -0
- package/src/reStructure/TemplateData/relationshipPerAction/moveRelationship/action/functionYaml/templateByHandler/apiTemplate.ejs +20 -0
- package/src/reStructure/TemplateData/relationshipPerAction/moveRelationship/action/functionYaml/templateByHandler/dsqTemplate.ejs +17 -0
- package/src/reStructure/TemplateData/relationshipPerAction/moveRelationship/action/functionYaml/templateByHandler/invTemplate.ejs +13 -0
- package/src/reStructure/TemplateData/relationshipPerAction/moveRelationship/action/functionYaml/templateByHandler/sqsTemplate.ejs +17 -0
- package/src/reStructure/TemplateData/relationshipPerAction/moveRelationship/action/handler/data.js +73 -0
- package/src/reStructure/TemplateData/relationshipPerAction/moveRelationship/action/handler/template.ejs +9 -0
- package/src/reStructure/TemplateData/relationshipPerAction/moveRelationship/action/handler/templateByHandler/apiTemplate.ejs +172 -0
- package/src/reStructure/TemplateData/relationshipPerAction/moveRelationship/action/handler/templateByHandler/dsqTemplate.ejs +218 -0
- package/src/reStructure/TemplateData/relationshipPerAction/moveRelationship/action/handler/templateByHandler/invTemplate.ejs +161 -0
- package/src/reStructure/TemplateData/relationshipPerAction/moveRelationship/action/handler/templateByHandler/sqsTemplate.ejs +197 -0
- package/src/reStructure/TemplateData/relationshipPerAction/moveRelationship/action/mainFunction/data.js +59 -0
- package/src/reStructure/TemplateData/relationshipPerAction/moveRelationship/action/mainFunction/template.ejs +386 -0
- package/src/reStructure/TemplateData/relationshipPerAction/moveRelationship/action/sns-in-sqs/data.js +77 -0
- package/src/reStructure/TemplateData/relationshipPerAction/moveRelationship/action/sns-in-sqs/snsTemplate.ejs +59 -0
- package/src/reStructure/TemplateData/relationshipPerAction/moveRelationship/action/sns-in-sqs/sqsTemplate.ejs +43 -0
- package/src/reStructure/TemplateData/relationshipPerAction/moveRelationship/complete/functionYaml/data.js +121 -0
- package/src/reStructure/TemplateData/relationshipPerAction/moveRelationship/complete/functionYaml/template.ejs +20 -0
- package/src/reStructure/TemplateData/relationshipPerAction/moveRelationship/complete/handler/sqs/data.js +60 -0
- package/src/reStructure/TemplateData/relationshipPerAction/moveRelationship/complete/handler/sqs/template.ejs +129 -0
- package/src/reStructure/TemplateData/relationshipPerAction/moveRelationship/complete/mainFunction/data.js +56 -0
- package/src/reStructure/TemplateData/relationshipPerAction/moveRelationship/complete/mainFunction/template.ejs +159 -0
- package/src/reStructure/TemplateData/relationshipPerAction/moveRelationship/complete/sns-in-sqs/data.js +71 -0
- package/src/reStructure/TemplateData/relationshipPerAction/moveRelationship/complete/sns-in-sqs/template.ejs +46 -0
- package/src/reStructure/TemplateData/relationshipPerAction/moveRelationship/complete/sns-out/data.js +71 -0
- package/src/reStructure/TemplateData/relationshipPerAction/moveRelationship/complete/sns-out/template.ejs +10 -0
- package/src/reStructure/TemplateData/relationshipPerAction/update/action/functionYaml/api/data.js +2 -2
- package/src/reStructure/TemplateData/relationshipPerAction/update/action/functionYaml/data.js +164 -0
- package/src/reStructure/TemplateData/relationshipPerAction/update/action/functionYaml/dsq/data.js +2 -2
- package/src/reStructure/TemplateData/relationshipPerAction/update/action/functionYaml/inv/data.js +2 -2
- package/src/reStructure/TemplateData/relationshipPerAction/update/action/functionYaml/sqs/data.js +1 -1
- package/src/reStructure/TemplateData/relationshipPerAction/update/action/functionYaml/template.ejs +9 -0
- package/src/reStructure/TemplateData/relationshipPerAction/update/action/functionYaml/templateByHandler/apiTemplate.ejs +20 -0
- package/src/reStructure/TemplateData/relationshipPerAction/update/action/functionYaml/templateByHandler/dsqTemplate.ejs +17 -0
- package/src/reStructure/TemplateData/relationshipPerAction/update/action/functionYaml/templateByHandler/invTemplate.ejs +13 -0
- package/src/reStructure/TemplateData/relationshipPerAction/update/action/functionYaml/templateByHandler/sqsTemplate.ejs +17 -0
- package/src/reStructure/TemplateData/relationshipPerAction/update/action/handler/data.js +73 -0
- package/src/reStructure/TemplateData/relationshipPerAction/update/action/handler/template.ejs +9 -0
- package/src/reStructure/TemplateData/relationshipPerAction/update/action/handler/templateByHandler/apiTemplate.ejs +155 -0
- package/src/reStructure/TemplateData/relationshipPerAction/update/action/handler/templateByHandler/dsqTemplate.ejs +202 -0
- package/src/reStructure/TemplateData/relationshipPerAction/update/action/handler/templateByHandler/invTemplate.ejs +144 -0
- package/src/reStructure/TemplateData/relationshipPerAction/update/action/handler/templateByHandler/sqsTemplate.ejs +181 -0
- package/src/reStructure/TemplateData/relationshipPerAction/update/complete/functionYaml/data.js +1 -1
- package/src/reStructure/TemplateData/resourceYaml/dynamodb/mainResourcePerObjectSchemaData.js +8 -7
- package/src/reStructure/TemplateData/resourceYaml/filterGenerateResource/data.js +36 -30
- package/src/reStructure/TemplateData/resourceYaml/generateTemplateData.js +3 -3
|
@@ -0,0 +1,181 @@
|
|
|
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
|
+
const izara = require("@izara_project/izara-middleware");
|
|
20
|
+
const middleware = izara.middlewareHandler;
|
|
21
|
+
const callingFlowSharedLib = require('@izara_project/izara-core-library-calling-flow');
|
|
22
|
+
const {
|
|
23
|
+
validateSchemaMiddleware
|
|
24
|
+
} = require('@izara_project/izara-market-library-service-schemas/src/GenerateCodeLibs/src/GenerateCodeLibs');
|
|
25
|
+
const Logger = require('@izara_project/izara-core-library-logger');
|
|
26
|
+
const recordHandlerSharedLib = require('@izara_project/izara-core-library-record-handler');
|
|
27
|
+
|
|
28
|
+
const <%- functionName %> = require('./<%- firstLetterUpperCase(functionName) %>_Main');
|
|
29
|
+
|
|
30
|
+
middleware.setValidatorSchema(recordHandlerSharedLib.baseValidatorSchema());
|
|
31
|
+
|
|
32
|
+
// validate event params in middleware before into function
|
|
33
|
+
let validatorSchema = {
|
|
34
|
+
type: "object",
|
|
35
|
+
required: [
|
|
36
|
+
'firstObject',
|
|
37
|
+
'secondObject',
|
|
38
|
+
'oldReltypeAndDirection',
|
|
39
|
+
'newRelType',
|
|
40
|
+
],
|
|
41
|
+
properties: {
|
|
42
|
+
firstObject: {
|
|
43
|
+
type: 'object',
|
|
44
|
+
required: ['objType', 'identifiers'],
|
|
45
|
+
properties: {
|
|
46
|
+
objType: {
|
|
47
|
+
type: 'object',
|
|
48
|
+
required: ['objectType', 'serviceTag'],
|
|
49
|
+
properties: {
|
|
50
|
+
serviceTag: izara.validatorSchema.stringNotEmpty(),
|
|
51
|
+
objectType: izara.validatorSchema.stringNotEmpty(),
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
identifiers: {
|
|
55
|
+
type: "object",
|
|
56
|
+
minProperties: 1
|
|
57
|
+
},
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
secondObject: {
|
|
61
|
+
type: 'object',
|
|
62
|
+
required: ['objType', 'identifiers'],
|
|
63
|
+
properties: {
|
|
64
|
+
objType: {
|
|
65
|
+
type: 'object',
|
|
66
|
+
required: ['objectType', 'serviceTag'],
|
|
67
|
+
properties: {
|
|
68
|
+
serviceTag: izara.validatorSchema.stringNotEmpty(),
|
|
69
|
+
objectType: izara.validatorSchema.stringNotEmpty(),
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
identifiers: {
|
|
73
|
+
type: "object",
|
|
74
|
+
minProperties: 1
|
|
75
|
+
},
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
oldReltypeAndDirection: {
|
|
79
|
+
type: 'object',
|
|
80
|
+
required: ['relType', 'relationshipDirection'],
|
|
81
|
+
properties: {
|
|
82
|
+
relType: {
|
|
83
|
+
type: 'object',
|
|
84
|
+
required: ['serviceTag', 'relationshipTag'],
|
|
85
|
+
properties: {
|
|
86
|
+
serviceTag: izara.validatorSchema.stringNotEmpty(),
|
|
87
|
+
relationshipTag: izara.validatorSchema.stringNotEmpty(),
|
|
88
|
+
}
|
|
89
|
+
},
|
|
90
|
+
relationshipProperties: {
|
|
91
|
+
type: 'object',
|
|
92
|
+
},
|
|
93
|
+
relationshipDirection: {
|
|
94
|
+
type: 'string',
|
|
95
|
+
enum: ['from', 'to']
|
|
96
|
+
|
|
97
|
+
},
|
|
98
|
+
}
|
|
99
|
+
},
|
|
100
|
+
newRelType: {
|
|
101
|
+
type: 'object',
|
|
102
|
+
required: ['serviceTag', 'relationshipTag'],
|
|
103
|
+
properties: {
|
|
104
|
+
serviceTag: izara.validatorSchema.stringNotEmpty(),
|
|
105
|
+
relationshipTag: izara.validatorSchema.stringNotEmpty(),
|
|
106
|
+
}
|
|
107
|
+
},
|
|
108
|
+
settings: {
|
|
109
|
+
type: 'object'
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
//(<globalVariable>
|
|
116
|
+
//</globalVariable>)
|
|
117
|
+
|
|
118
|
+
// validate event params in middleware before into main function
|
|
119
|
+
validatorSchema = callingFlowSharedLib.addOptionalCallingFlowToValidatorSchema(validatorSchema);
|
|
120
|
+
// if need to validate authorizer or additional params , add code to hook tag below
|
|
121
|
+
|
|
122
|
+
//(<afterValidateWith>)
|
|
123
|
+
//(</afterValidateWith>)
|
|
124
|
+
|
|
125
|
+
module.exports.main = middleware.wrap(async (event, context, callback) => {
|
|
126
|
+
|
|
127
|
+
try {
|
|
128
|
+
|
|
129
|
+
let recordPromises = []; // final return
|
|
130
|
+
|
|
131
|
+
// loop each record and send to mainFunction
|
|
132
|
+
await Promise.all(event.Records.map(async record => { // promise.all for map() function
|
|
133
|
+
|
|
134
|
+
let passOnProperties = []
|
|
135
|
+
|
|
136
|
+
// --- validate message (and MessageAttributes)
|
|
137
|
+
await recordHandlerSharedLib.validateRecord(
|
|
138
|
+
record, // one record will send to mainFunction
|
|
139
|
+
"<%-firstLetterUpperCase(queueName) %>", // queue name that need to retry or send to dlq
|
|
140
|
+
validatorSchema, // schema for record.Message
|
|
141
|
+
// messageAttributeValidatorSchema // ----- for msgAttr default is null -> do not send this parameter if not want to validate msgAtt
|
|
142
|
+
);
|
|
143
|
+
|
|
144
|
+
// add argument (to invoke lambda) to passOnProperties[]
|
|
145
|
+
passOnProperties.push(record.body.Message)
|
|
146
|
+
passOnProperties.push(callingFlowSharedLib.addCallingFlowToPassOnProperties(record.body.Message));
|
|
147
|
+
//(<afterPutParamIntoMainFunction>)
|
|
148
|
+
//(</afterPutParamIntoMainFunction>)
|
|
149
|
+
|
|
150
|
+
record._izContext.logger.debug('passOnProperties in handler', passOnProperties);
|
|
151
|
+
|
|
152
|
+
// call recordHandlerSharedLib.recordHandler with 3 parameters and return promise(resolve)
|
|
153
|
+
let recordPromise = recordHandlerSharedLib.recordHandler(
|
|
154
|
+
record, // one record will send to mainFunction
|
|
155
|
+
<%- functionName %>.<%- functionName %>, // mainFunction that need to invoke.
|
|
156
|
+
"<%-firstLetterUpperCase(queueName) %>", // queue name that need to retry or send to dlq
|
|
157
|
+
passOnProperties, // all parameters that mainFunction needed.
|
|
158
|
+
);
|
|
159
|
+
record._izContext.logger.debug('after recordPromise in handler');
|
|
160
|
+
recordPromises.push(recordPromise); // push promise to recordPromises
|
|
161
|
+
})) //end record
|
|
162
|
+
|
|
163
|
+
Logger.debug('before Promise.all(recordPromises) in handler');
|
|
164
|
+
try {
|
|
165
|
+
await Promise.all(recordPromises); // await all promises
|
|
166
|
+
return event.Records // return all for local test
|
|
167
|
+
} catch {
|
|
168
|
+
Logger.debug('Promise.all(recordPromises) in handler threw error (at least one record did no resolve)');
|
|
169
|
+
}
|
|
170
|
+
Logger.debug('after Promise.all(recordPromises) in handler');
|
|
171
|
+
} catch (err) {
|
|
172
|
+
Logger.error('Unhandled Error, updateRelationshipHdrDsq:', err);
|
|
173
|
+
throw (err);
|
|
174
|
+
}
|
|
175
|
+
});
|
|
176
|
+
<%_ function firstLetterUpperCase(text) {
|
|
177
|
+
return text.charAt(0).toUpperCase() + text.slice(1)
|
|
178
|
+
} _%>
|
|
179
|
+
<%_ function firstLetterLowerCase(str) {
|
|
180
|
+
return str.charAt(0).toLowerCase() + str.slice(1)
|
|
181
|
+
} _%>
|
package/src/reStructure/TemplateData/relationshipPerAction/update/complete/functionYaml/data.js
CHANGED
|
@@ -101,7 +101,7 @@ function createParamForCreateSource(srcPath) {
|
|
|
101
101
|
handlerType,
|
|
102
102
|
additionalResourcePermission,
|
|
103
103
|
resourceLocation: SOURCE_PATH.resourceLocationRelationshipPerAction,
|
|
104
|
-
functionNameConfig: upperCase(SHORT_FUNCTION_NAME.updateRelComplete),
|
|
104
|
+
functionNameConfig: upperCase(SHORT_FUNCTION_NAME(FUNCTION_NAME.updateRelComplete)),
|
|
105
105
|
roleName: SOURCE_GENERATE_IAM_ROLE.RelationshipCompleteRole
|
|
106
106
|
},
|
|
107
107
|
setting: {
|
package/src/reStructure/TemplateData/resourceYaml/dynamodb/mainResourcePerObjectSchemaData.js
CHANGED
|
@@ -49,7 +49,7 @@ const { getLocalConfig } = require('../../../../MainLibs/src/Utils.js')
|
|
|
49
49
|
*/
|
|
50
50
|
|
|
51
51
|
function dataForMainDynamoDbYamlFromObjectSchema(_izContext, objectSchema, srcPath) {
|
|
52
|
-
let
|
|
52
|
+
let dynamoDbYamlTemplateData = [];
|
|
53
53
|
|
|
54
54
|
let identifierDetail = {};
|
|
55
55
|
for (let identifier of objectSchema.identifiers) { //check identifiers from objectSchema
|
|
@@ -119,10 +119,11 @@ function dataForMainDynamoDbYamlFromObjectSchema(_izContext, objectSchema, srcPa
|
|
|
119
119
|
// if (storageResource.hasOwnProperty("serviceTag") && storageResource.serviceTag !== getLocalConfig(srcPath)) {
|
|
120
120
|
// continue; // if serviceTag of storageResource not own service will skip
|
|
121
121
|
// }
|
|
122
|
+
|
|
122
123
|
if (storageResource.storageType === STORAGE_TYPES.dynamoDB) {
|
|
123
124
|
let templateData = {
|
|
124
|
-
tableName: storageResource.tableName,
|
|
125
|
-
resourceName: storageResource.tableName,
|
|
125
|
+
tableName: upperCase(storageResource.tableName),
|
|
126
|
+
resourceName: upperCase(storageResource.tableName),
|
|
126
127
|
attributes: []
|
|
127
128
|
};
|
|
128
129
|
if (storageResource.hasOwnProperty("groupByPartitionKeyField")) {
|
|
@@ -145,11 +146,11 @@ function dataForMainDynamoDbYamlFromObjectSchema(_izContext, objectSchema, srcPa
|
|
|
145
146
|
}
|
|
146
147
|
}
|
|
147
148
|
// templateData.resourceName = upperCase(objectSchema.objectType)
|
|
148
|
-
|
|
149
|
+
dynamoDbYamlTemplateData.push(templateData)
|
|
149
150
|
}
|
|
150
151
|
}
|
|
151
|
-
|
|
152
|
-
return
|
|
152
|
+
// console.log("dynamoDbYamlTemplateData", dynamoDbYamlTemplateData)
|
|
153
|
+
return dynamoDbYamlTemplateData
|
|
153
154
|
}
|
|
154
155
|
|
|
155
156
|
const createSourceDataDynamoDB = (_izContext, objectSchema, srcPath) => {
|
|
@@ -158,7 +159,7 @@ const createSourceDataDynamoDB = (_izContext, objectSchema, srcPath) => {
|
|
|
158
159
|
|
|
159
160
|
|
|
160
161
|
const dynamoDbMainYamlDataList = dataForMainDynamoDbYamlFromObjectSchema(_izContext, objectSchema, srcPath)
|
|
161
|
-
|
|
162
|
+
// console.log("generateDynamoPerObjectSchema", objectSchema)
|
|
162
163
|
for (let dynamoDbMainYamlData of dynamoDbMainYamlDataList) {
|
|
163
164
|
resultsForCreateSource.push({
|
|
164
165
|
templatePath: templatePath,
|
|
@@ -30,53 +30,59 @@ const STORAGE_TYPES = {
|
|
|
30
30
|
graph: "graph"
|
|
31
31
|
}
|
|
32
32
|
const { SOURCE_PATH, SAVE_FILE_NAME } = require('../../../../MainLibs/src/Consts')
|
|
33
|
-
const {
|
|
33
|
+
const { firstLetterUpperCase: upperCase, getLocalConfig } = require('../../../../MainLibs/src/Utils')
|
|
34
34
|
const getObjectSchema = require('@izara_project/izara-core-library-service-schemas/src/GetObjectSchema');
|
|
35
35
|
const { NoRetryError } = require("@izara_project/izara-core-library-core");
|
|
36
36
|
|
|
37
37
|
async function filterCreateResourceYaml(_izContext, createSourceParams, objSchemaPath) {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
if (storageResource
|
|
56
|
-
|
|
38
|
+
try {
|
|
39
|
+
let tableNamesToFilter = new Set();
|
|
40
|
+
let ownServiceTag = getLocalConfig(path.join(objSchemaPath, "../../"), "iz_serviceTag")
|
|
41
|
+
|
|
42
|
+
const allLocalFlowSchema = await getObjectSchema.getAllLocalFlowSchemas(_izContext, objSchemaPath);
|
|
43
|
+
await Promise.all(allLocalFlowSchema.records.map(async (flowSchema) => {
|
|
44
|
+
if (flowSchema.statusType === "storedCache") {
|
|
45
|
+
tableNamesToFilter.add(...await getTableNameFromFlowSchema(_izContext, flowSchema, objSchemaPath))
|
|
46
|
+
} else if (flowSchema.statusType === "triggerCache") {
|
|
47
|
+
tableNamesToFilter.add(...await getTableNameFromFlowSchema(_izContext, flowSchema, objSchemaPath))
|
|
48
|
+
}
|
|
49
|
+
}))
|
|
50
|
+
|
|
51
|
+
const allLocalObjSchema = await getObjectSchema.getAllLocalObjectSchemasWithHierarchy(_izContext, objSchemaPath);
|
|
52
|
+
await Promise.all(allLocalObjSchema.records.map(async (objSchema) => {
|
|
53
|
+
if (objSchema.hasOwnProperty("extendObjType")) {
|
|
54
|
+
for (const storageResource of Object.values(objSchema.storageResources)) {
|
|
55
|
+
if (storageResource.storageType === STORAGE_TYPES.dynamoDB) {
|
|
56
|
+
if (storageResource?.serviceTag !== ownServiceTag) {
|
|
57
|
+
tableNamesToFilter.has(storageResource.tableName)
|
|
58
|
+
}
|
|
57
59
|
}
|
|
58
60
|
}
|
|
59
61
|
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
+
}))
|
|
63
|
+
|
|
62
64
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
65
|
+
console.log("tableNamesToFilter", tableNamesToFilter)
|
|
66
|
+
let filteredCreateSourceParams = createSourceParams.filter(
|
|
67
|
+
(result) => !tableNamesToFilter.has(result.templateData.tableName)
|
|
68
|
+
)
|
|
66
69
|
|
|
67
|
-
|
|
68
|
-
|
|
70
|
+
// console.log("filteredCreateSourceParams", filteredCreateSourceParams)
|
|
71
|
+
return filteredCreateSourceParams
|
|
72
|
+
} catch (err) {
|
|
73
|
+
console.log(err)
|
|
74
|
+
}
|
|
69
75
|
}
|
|
70
76
|
|
|
71
77
|
module.exports = filterCreateResourceYaml;
|
|
72
78
|
|
|
73
|
-
async function
|
|
74
|
-
let tableNameStoredCache =
|
|
79
|
+
async function getTableNameFromFlowSchema(_izContext, flowSchema, objSchemaPath) {
|
|
80
|
+
let tableNameStoredCache = [];
|
|
75
81
|
const objectSchema = await getObjectSchema.getLocalObjectSchemas(_izContext, [flowSchema.objType.objectType], objSchemaPath).then(res => res.records[0])
|
|
76
82
|
if (objectSchema) {
|
|
77
83
|
for (const storageResource of Object.values(objectSchema.storageResources)) {
|
|
78
84
|
if (storageResource.storageType === STORAGE_TYPES.dynamoDB) {
|
|
79
|
-
tableNameStoredCache.
|
|
85
|
+
tableNameStoredCache.push(upperCase(storageResource.tableName));
|
|
80
86
|
}
|
|
81
87
|
}
|
|
82
88
|
} else {
|
|
@@ -61,7 +61,6 @@ async function generateCodeWithTemplate(_izContext, objSchemaPath) {
|
|
|
61
61
|
try {
|
|
62
62
|
|
|
63
63
|
let createSourceDynamoDb = createSourceDataDynamoDB(_izContext, objectSchema, saveFilePath)
|
|
64
|
-
|
|
65
64
|
const [dynamoResources, updatedTableYaml] = checkValidTableYaml(
|
|
66
65
|
_izContext,
|
|
67
66
|
createSourceDynamoDb,
|
|
@@ -78,7 +77,6 @@ async function generateCodeWithTemplate(_izContext, objSchemaPath) {
|
|
|
78
77
|
}
|
|
79
78
|
}
|
|
80
79
|
}
|
|
81
|
-
|
|
82
80
|
// Add default resources
|
|
83
81
|
const defaultDynamoDbResources = createDefaultDynamoDb(_izContext, saveFilePath);
|
|
84
82
|
const defaultSnsInSqsResources = createFindDataAndProcessLogicalDefaultSnsInSqs(_izContext, saveFilePath);
|
|
@@ -97,9 +95,11 @@ async function generateCodeWithTemplate(_izContext, objSchemaPath) {
|
|
|
97
95
|
...dynamoDbResourcePerRelationshipLink
|
|
98
96
|
)
|
|
99
97
|
}
|
|
98
|
+
|
|
99
|
+
// console.log("createSourceParams before filter", createSourceParams)
|
|
100
100
|
const filteredCreateSourceParams = await filterCreateResourceYaml(_izContext, createSourceParams, objSchemaPath);
|
|
101
101
|
|
|
102
|
-
|
|
102
|
+
console.log("filteredCreateSourceParams", filteredCreateSourceParams);
|
|
103
103
|
|
|
104
104
|
return filteredCreateSourceParams;
|
|
105
105
|
} catch (error) {
|