@izara_project/izara-market-library-service-schemas 1.0.60 → 1.0.63
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 +1 -1
- package/src/GenerateCodeLibs/src/Consts.js +7 -3
- package/src/MainLibs/src/Consts.js +7 -2
- package/src/reStructure/GenerateCode.js +1 -1
- package/src/reStructure/TemplateData/EndpointPerService/mainFunction/create/template.ejs +24 -61
- package/src/reStructure/TemplateData/EndpointPerService/mainFunction/get/template.ejs +3 -3
- package/src/reStructure/TemplateData/EndpointPerService/mainFunction/update/template.ejs +141 -105
- package/src/reStructure/TemplateData/externalService/lambdaRole/data.js +8 -0
- package/src/reStructure/TemplateData/externalService/snsTopicSubscriptions/data.js +11 -1
- package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/createPresignUrl/mainFunction/template.ejs +4 -4
- package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/reservedLimit/functionYaml/data.js +3 -2
- package/src/reStructure/TemplateData/flowSchema/externalTopic/Process/handler/template.ejs +0 -3
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaComponent/handler/template.ejs +13 -9
- package/src/reStructure/TemplateData/flowSchema/generateTemplateData.js +3 -2
- package/src/reStructure/TemplateData/flowSchema/register/complete/handler/template.ejs +1 -0
- package/src/reStructure/TemplateData/flowSchema/register/complete/mainFunction/template.ejs +44 -35
- package/src/reStructure/TemplateData/flowSchema/register/wbs/mainFunction/template.ejs +7 -2
- package/src/reStructure/TemplateData/propertyValueSchema/objectPropertyValueSchema/data.js +12 -4
- package/src/reStructure/TemplateData/propertyValueSchema/relationshipPropertyValueSchema/data.js +14 -5
- package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/functionYaml/api/data.js +123 -0
- package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/functionYaml/api/template.ejs +20 -0
- package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/functionYaml/dsq/data.js +122 -0
- package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/functionYaml/dsq/template.ejs +17 -0
- package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/functionYaml/inv/data.js +123 -0
- package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/functionYaml/inv/template.ejs +13 -0
- package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/functionYaml/sqs/data.js +123 -0
- package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/functionYaml/sqs/template.ejs +17 -0
- package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/handler/api/data.js +57 -0
- package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/handler/api/request.json +0 -0
- package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/handler/api/template.ejs +155 -0
- package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/handler/dsq/data.js +58 -0
- package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/handler/dsq/request.json +0 -0
- package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/handler/dsq/template.ejs +202 -0
- package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/handler/inv/data.js +59 -0
- package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/handler/inv/request.json +0 -0
- package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/handler/inv/template.ejs +144 -0
- package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/handler/sqs/data.js +59 -0
- package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/handler/sqs/request.json +0 -0
- package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/handler/sqs/template.ejs +181 -0
- package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/mainFunction/data.js +59 -0
- package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/mainFunction/template.ejs +382 -0
- package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/sns-in-sqs/data.js +77 -0
- package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/sns-in-sqs/snsTemplate.ejs +59 -0
- package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/sns-in-sqs/sqsTemplate.ejs +43 -0
- package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/complete/functionYaml/data.js +121 -0
- package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/complete/functionYaml/template.ejs +20 -0
- package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/complete/handler/sqs/data.js +60 -0
- package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/complete/handler/sqs/template.ejs +129 -0
- package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/complete/mainFunction/data.js +55 -0
- package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/complete/mainFunction/template.ejs +154 -0
- package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/complete/sns-in-sqs/data.js +71 -0
- package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/complete/sns-in-sqs/template.ejs +46 -0
- package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/complete/sns-out/data.js +71 -0
- package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/complete/sns-out/template.ejs +10 -0
- package/src/reStructure/TemplateData/relationshipPerAction/create/complete/handler/sqs/template.ejs +2 -2
- package/src/reStructure/TemplateData/relationshipPerAction/generateTemplateData.js +55 -2
|
@@ -57,9 +57,6 @@ module.exports.main = middleware.wrap(async (event, context, callback) => {
|
|
|
57
57
|
// loop each record and send to mainFunction
|
|
58
58
|
await Promise.all(event.Records.map(async record => { // promise.all for map() function
|
|
59
59
|
|
|
60
|
-
record = recordHandlerSharedLib.reformatDsqMessage(record._izContext, record);
|
|
61
|
-
record._izContext.logger.debug('record LambdaFunctionHdrDsq after reform', record);
|
|
62
|
-
|
|
63
60
|
let passOnProperties = []
|
|
64
61
|
record._izContext.logger.debug('record ReceiveMsgOutHdrSqs', record);
|
|
65
62
|
|
|
@@ -21,14 +21,16 @@ const izara = require("@izara_project/izara-middleware");
|
|
|
21
21
|
const middleware = izara.middlewareHandler;
|
|
22
22
|
// const AWS = require('aws-sdk');
|
|
23
23
|
// const api = new AWS.ApiGatewayManagementApi({ endpoint: process.env.iz_webSocketEndpoint });
|
|
24
|
-
const dynamodbSharedLib = require('@izara_project/izara-core-library-dynamodb')
|
|
25
|
-
const callingFlowSharedLib = require('@izara_project/izara-core-library-calling-flow')
|
|
24
|
+
const dynamodbSharedLib = require('@izara_project/izara-core-library-dynamodb');
|
|
25
|
+
const callingFlowSharedLib = require('@izara_project/izara-core-library-calling-flow');
|
|
26
26
|
const hash = require('@izara_project/izara-shared-core').objectHash;
|
|
27
27
|
// const coreConsts = require("@izara_project/izara-core-library-core/src/Consts");
|
|
28
|
-
const consts = require('@izara_project/izara-middleware/src/MiddlewareCore/Consts')
|
|
29
|
-
const { postToConnection } = require('../../../libs/source/GenerateCodeLibs')
|
|
28
|
+
const consts = require('@izara_project/izara-middleware/src/MiddlewareCore/Consts');
|
|
29
|
+
const { postToConnection } = require('../../../libs/source/GenerateCodeLibs');
|
|
30
30
|
const <%- functionName %> = require('./<%- functionName %>_Main');
|
|
31
|
-
const { createFlowTypeConcat } = require("@izara_project/izara-core-library-service-schemas").utils
|
|
31
|
+
const { createFlowTypeConcat } = require("@izara_project/izara-core-library-service-schemas").utils;
|
|
32
|
+
const getObjectSchema = require('@izara_project/izara-core-library-service-schemas').getObjectSchema;
|
|
33
|
+
|
|
32
34
|
module.exports.main = middleware.wrap(async (event, context, callback) => {
|
|
33
35
|
|
|
34
36
|
event._izContext.logger.debug('Event:', event);
|
|
@@ -40,9 +42,6 @@ module.exports.main = middleware.wrap(async (event, context, callback) => {
|
|
|
40
42
|
const connectionId = event.requestContext.connectionId;
|
|
41
43
|
let correlationId = event._izContext.correlationIds.get(consts.X_CORRELATION_ID)
|
|
42
44
|
|
|
43
|
-
//(<createIdentifiersFlow>)
|
|
44
|
-
let identifiers
|
|
45
|
-
//(</createIdentifiersFlow>)
|
|
46
45
|
|
|
47
46
|
switch (route) {
|
|
48
47
|
|
|
@@ -52,7 +51,12 @@ module.exports.main = middleware.wrap(async (event, context, callback) => {
|
|
|
52
51
|
case '<%- route %>':
|
|
53
52
|
console.log("event in route webSocket", event);
|
|
54
53
|
let eventParams = JSON.parse(event.body)
|
|
55
|
-
|
|
54
|
+
|
|
55
|
+
//(<createIdentifiersFlow>)
|
|
56
|
+
let identifiers
|
|
57
|
+
//(</createIdentifiersFlow>)
|
|
58
|
+
|
|
59
|
+
let flowSchema = await getObjectSchema.getFlowSchemaS3WithCache(
|
|
56
60
|
event._izContext,
|
|
57
61
|
{
|
|
58
62
|
flowTag: "<%- route %>",
|
|
@@ -164,8 +164,9 @@ async function generateCodeWithTemplate(_izContext, objSchemaPath) {
|
|
|
164
164
|
const webSocketCompleteMainFunction = createWebSocketCompleteMainMainFunction(_izContext, saveFilePath);
|
|
165
165
|
const webSocketCompleteSqs = createWebSocketCompleteMainSqs(_izContext, allLocalFlowSchemas, saveFilePath)
|
|
166
166
|
const webSocketCompleteComponent = [...webSocketCompleteFunctionYaml, ...webSocketCompleteHandler, ...webSocketCompleteMainFunction, ...webSocketCompleteSqs]
|
|
167
|
+
const userUploadRecordTable = createUserUploadRecordTable(_izContext, saveFilePath)
|
|
167
168
|
|
|
168
|
-
const webSocketResource = [...webSocketTaskTable, ...webSocketConnectYaml, ...webSocketConnectHandler]
|
|
169
|
+
const webSocketResource = [...webSocketTaskTable, ...webSocketConnectYaml, ...webSocketConnectHandler, ...userUploadRecordTable]
|
|
169
170
|
if (allLocalFlowSchemas.records.length) {
|
|
170
171
|
createSourceParams.push(
|
|
171
172
|
...webSocketResource,
|
|
@@ -180,6 +181,7 @@ async function generateCodeWithTemplate(_izContext, objSchemaPath) {
|
|
|
180
181
|
for (const flowSchema of allLocalFlowSchemas.records) {
|
|
181
182
|
// console.log("flowSchema in Generate TemplateData", flowSchema);
|
|
182
183
|
const webSocketGenerateCodeLibs = createWebSocketGenerateCodeLibs(_izContext, flowSchema, saveFilePath)
|
|
184
|
+
|
|
183
185
|
createSourceParams.push(...webSocketGenerateCodeLibs)
|
|
184
186
|
if (!flowSchema.event.includes("s3")) {
|
|
185
187
|
const flowSchemaEndpointMainFunction = await createFlowSchemaEndpointMainFunction(_izContext, flowSchema, saveFilePath);
|
|
@@ -191,7 +193,6 @@ async function generateCodeWithTemplate(_izContext, objSchemaPath) {
|
|
|
191
193
|
if (event.includes("s3")) {
|
|
192
194
|
const reservedDataTable = createReservedDataMainTable(_izContext, saveFilePath);
|
|
193
195
|
const bucketS3 = createBucketS3(_izContext, flowSchema, saveFilePath)
|
|
194
|
-
const userUploadRecordTable = createUserUploadRecordTable(_izContext, saveFilePath)
|
|
195
196
|
|
|
196
197
|
const functionYamlCreateObjectWebSocket = createFunctionYamlCreateObjectWebSocket(_izContext, flowSchema, saveFilePath);
|
|
197
198
|
const handlerCreateObjectWebSocket = createHandlerCreateObjectWebSocket(_izContext, flowSchema, saveFilePath);
|
|
@@ -23,6 +23,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
23
23
|
const { middlewareHandler } = require("@izara_project/izara-middleware");
|
|
24
24
|
const recordHandlerSharedLib = require("@izara_project/izara-core-library-record-handler")
|
|
25
25
|
const Logger = require('@izara_project/izara-core-library-logger');
|
|
26
|
+
const callingFlowSharedLib = require('@izara_project/izara-core-library-calling-flow');
|
|
26
27
|
|
|
27
28
|
const { <%- functionName %>Main } =require('./<%- firstLetterUpperCase(functionName) %>_Main.js')
|
|
28
29
|
|
|
@@ -20,7 +20,6 @@ along with this program. If not, see
|
|
|
20
20
|
|
|
21
21
|
const hash = require('@izara_project/izara-shared-core').objectHash;
|
|
22
22
|
const { getObjectSchema, identifiersObject } = require('@izara_project/izara-core-library-service-schemas');
|
|
23
|
-
|
|
24
23
|
const dynamodbSharedLib = require('@izara_project/izara-core-library-dynamodb');
|
|
25
24
|
const snsSharedLib = require('@izara_project/izara-core-library-sns');
|
|
26
25
|
const asyncFlowSharedLib = require('@izara_project/izara-core-library-asynchronous-flow');
|
|
@@ -62,9 +61,8 @@ module.exports.registerCompleteMain = async (
|
|
|
62
61
|
_izContext.logger.debug("WebSocketInvoke requestParams", requestParams)
|
|
63
62
|
_izContext.logger.debug("WebSocketInvoke callingFlowConfig", callingFlowConfig)
|
|
64
63
|
|
|
65
|
-
let connectionId = _izContext.correlationIds.get(consts.CONNECTION_ID);
|
|
66
64
|
|
|
67
|
-
if (!topicArn){
|
|
65
|
+
if (!topicArn) {
|
|
68
66
|
throw new NoRetryError("invalid not have topicArn to get flowSchema")
|
|
69
67
|
}
|
|
70
68
|
|
|
@@ -78,7 +76,24 @@ module.exports.registerCompleteMain = async (
|
|
|
78
76
|
throw new NoRetryError("not have flowSchema in S3")
|
|
79
77
|
}
|
|
80
78
|
|
|
81
|
-
let
|
|
79
|
+
let identifiersTask = ""
|
|
80
|
+
|
|
81
|
+
if (!requestParams.identifiersTask && flowSchema.objType) {
|
|
82
|
+
|
|
83
|
+
identifiersTask = await identifiersObject.identifiersConcatFromIdentifiers(_izContext, flowSchema.objType, requestParams)
|
|
84
|
+
_izContext.logger.debug("identifiersTask from request params", identifiersTask)
|
|
85
|
+
|
|
86
|
+
Object.assign(requestParams, {
|
|
87
|
+
identifiersTask: identifiersTask
|
|
88
|
+
})
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
if (!requestParams.identifiersTask) {
|
|
92
|
+
_izContext.logger.warn("invalid identifiersTask")
|
|
93
|
+
return "invalid identifiersTask"
|
|
94
|
+
// throw new NoRetryError("invalid identifiersTask")
|
|
95
|
+
}
|
|
96
|
+
|
|
82
97
|
|
|
83
98
|
const getResult = async (objType) => {
|
|
84
99
|
const objectSchema = await getObjectSchema.getObjSchemaS3WithCache(
|
|
@@ -90,32 +105,31 @@ module.exports.registerCompleteMain = async (
|
|
|
90
105
|
|
|
91
106
|
_izContext.logger.debug("==> objectSchema", objectSchema)
|
|
92
107
|
|
|
93
|
-
|
|
94
|
-
|
|
108
|
+
// use object
|
|
109
|
+
let tasks = await dynamodbSharedLib.query(_izContext,
|
|
110
|
+
await dynamodbSharedLib.tableName(_izContext, "RegisterRecords"),
|
|
95
111
|
{
|
|
96
|
-
|
|
97
|
-
objectType: objType.objectType
|
|
112
|
+
identifiersTask: identifiersTask
|
|
98
113
|
}
|
|
99
114
|
)
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
{
|
|
110
|
-
identifiersTask: requestParams.identifiersTask,
|
|
111
|
-
connectionId: connectionId
|
|
112
|
-
}
|
|
113
|
-
)
|
|
114
|
-
} else {
|
|
115
|
-
await generatedCodeLibs.postToConnection({ message: result }, connectionId)
|
|
116
|
-
}
|
|
115
|
+
|
|
116
|
+
if (tasks.Items.length > 0) {
|
|
117
|
+
const result = await externalRequest.lambda.invokeSync(_izContext,
|
|
118
|
+
await lambdaSharedLib.lambdaFunctionName(_izContext, "GetHdrInv"),
|
|
119
|
+
{
|
|
120
|
+
identifiers: await identifiersObject.identifiersFromIdentifiersConcat(_izContext, objType, requestParams.identifiersTask),
|
|
121
|
+
objectType: objType.objectType,
|
|
122
|
+
//(<additionalParamsForGetData>)
|
|
123
|
+
//(</additionalParamsForGetData>)
|
|
117
124
|
}
|
|
118
|
-
|
|
125
|
+
)
|
|
126
|
+
await Promise.all(tasks.Items.map(async (task) => {
|
|
127
|
+
if (!result) {
|
|
128
|
+
await generatedCodeLibs.postToConnection({ message: "not have record" }, task.connectionId)
|
|
129
|
+
} else {
|
|
130
|
+
await generatedCodeLibs.postToConnection({ message: result }, task.connectionId)
|
|
131
|
+
}
|
|
132
|
+
}))
|
|
119
133
|
}
|
|
120
134
|
}
|
|
121
135
|
// check statusType
|
|
@@ -126,7 +140,9 @@ module.exports.registerCompleteMain = async (
|
|
|
126
140
|
case "storedCache":
|
|
127
141
|
await getResult(flowSchema.objType);
|
|
128
142
|
break;
|
|
129
|
-
|
|
143
|
+
case "triggerCache":
|
|
144
|
+
await getResult(flowSchema.objType)
|
|
145
|
+
break;
|
|
130
146
|
case "none":
|
|
131
147
|
|
|
132
148
|
let identifier = {};
|
|
@@ -154,15 +170,8 @@ module.exports.registerCompleteMain = async (
|
|
|
154
170
|
await generatedCodeLibs.postToConnection({ message: task }, task.connectionId)
|
|
155
171
|
}))
|
|
156
172
|
await generatedCodeLibs.postToConnection({ message: tasks.Items[0] }, connectionId)
|
|
157
|
-
} else {
|
|
158
|
-
await dynamodbSharedLib.putItem(_izContext,
|
|
159
|
-
await dynamodbSharedLib.tableName(_izContext, "RegisterRecords"),
|
|
160
|
-
{
|
|
161
|
-
identifiersTask: hash(identifier),
|
|
162
|
-
connectionId: connectionId
|
|
163
|
-
}
|
|
164
|
-
)
|
|
165
173
|
}
|
|
174
|
+
|
|
166
175
|
break
|
|
167
176
|
default:
|
|
168
177
|
throw new NoRetryError(`statusType not found ${flowSchema.statusType}`)
|
|
@@ -20,7 +20,7 @@ along with this program. If not, see
|
|
|
20
20
|
|
|
21
21
|
const hash = require('@izara_project/izara-shared-core').objectHash;
|
|
22
22
|
const { getObjectSchema, identifiersObject } = require('@izara_project/izara-core-library-service-schemas');
|
|
23
|
-
|
|
23
|
+
const lodash = require('lodash')
|
|
24
24
|
const dynamodbSharedLib = require('@izara_project/izara-core-library-dynamodb');
|
|
25
25
|
const snsSharedLib = require('@izara_project/izara-core-library-sns');
|
|
26
26
|
const asyncFlowSharedLib = require('@izara_project/izara-core-library-asynchronous-flow');
|
|
@@ -118,6 +118,9 @@ module.exports.registerMain = async (
|
|
|
118
118
|
case "storedCache":
|
|
119
119
|
await getResult(flowSchema.objType)
|
|
120
120
|
break;
|
|
121
|
+
case "triggerCache":
|
|
122
|
+
await getResult(flowSchema.objType)
|
|
123
|
+
break;
|
|
121
124
|
case "none":
|
|
122
125
|
let identifier = {};
|
|
123
126
|
if (requestParams.hasOwnProperty("identifiersField") && Array.isArray(requestParams.identifiersField)) {
|
|
@@ -128,7 +131,9 @@ module.exports.registerMain = async (
|
|
|
128
131
|
}
|
|
129
132
|
identifier = identifier;
|
|
130
133
|
} else {
|
|
131
|
-
|
|
134
|
+
let pureRequestParams = lodash.cloneDeep(requestParams);
|
|
135
|
+
delete pureRequestParams.flowTag
|
|
136
|
+
identifier = pureRequestParams
|
|
132
137
|
}
|
|
133
138
|
|
|
134
139
|
// get task before putItem
|
|
@@ -21,12 +21,14 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
21
21
|
|
|
22
22
|
const path = require('path');
|
|
23
23
|
const fs = require('fs');
|
|
24
|
+
const lodash = require('lodash')
|
|
24
25
|
const {
|
|
25
26
|
SOURCE_PATH,
|
|
26
27
|
fieldNameSetting,
|
|
27
28
|
FIELD_NAME_TYPE,
|
|
28
29
|
PROPERTY_VALUE_TAG,
|
|
29
|
-
SAVE_FILE_NAME
|
|
30
|
+
SAVE_FILE_NAME,
|
|
31
|
+
STORAGE_TYPES
|
|
30
32
|
} = require('../../../../MainLibs/src/Consts');
|
|
31
33
|
|
|
32
34
|
const templatePath = path.join(__dirname, "./templateObjectPropertyValueSchema.ejs");
|
|
@@ -66,7 +68,13 @@ async function data(_izContext, settings, srcPath) {
|
|
|
66
68
|
};
|
|
67
69
|
|
|
68
70
|
const storageResources = objectSchema.storageResources; // storageResource from main objectType
|
|
69
|
-
|
|
71
|
+
let cloneDeepStorageResources = lodash.cloneDeep(storageResources)
|
|
72
|
+
for (let [storageResourceTag, storageResourceSetting] of Object.entries(cloneDeepStorageResources)) {
|
|
73
|
+
if (storageResourceSetting.storageType === STORAGE_TYPES.dynamoDB) {
|
|
74
|
+
delete cloneDeepStorageResources[storageResourceTag]
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
const storageResourceTags = Object.keys(cloneDeepStorageResources); // storage ResourceTag from main objectType
|
|
70
78
|
const compositeKeyDeliminator = objectSchema.compositeKeyDeliminator;
|
|
71
79
|
|
|
72
80
|
propertyValueObjectSchemas.push(
|
|
@@ -98,11 +106,11 @@ async function data(_izContext, settings, srcPath) {
|
|
|
98
106
|
|
|
99
107
|
for (let propertyValueObjectSchema of propertyValueObjectSchemas) {
|
|
100
108
|
Object.assign(propertyValueObjectSchema, {
|
|
101
|
-
storageResources:
|
|
109
|
+
storageResources: cloneDeepStorageResources, // add storageResources
|
|
102
110
|
compositeKeyDeliminator: compositeKeyDeliminator
|
|
103
111
|
})
|
|
104
112
|
for (let attributeTreeFieldName of Object.values(propertyValueObjectSchema.fieldNames)) {
|
|
105
|
-
Object.assign(attributeTreeFieldName, { storageResourceTags:
|
|
113
|
+
Object.assign(attributeTreeFieldName, { storageResourceTags: storageResourceTags }) // add storageResourceTags for each fieldName
|
|
106
114
|
}
|
|
107
115
|
};
|
|
108
116
|
for (const propertyValueObjectSchema of propertyValueObjectSchemas) {
|
package/src/reStructure/TemplateData/propertyValueSchema/relationshipPropertyValueSchema/data.js
CHANGED
|
@@ -19,11 +19,13 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
19
19
|
|
|
20
20
|
const path = require('path');
|
|
21
21
|
const fs = require('fs');
|
|
22
|
+
const lodash = require('lodash')
|
|
22
23
|
const {
|
|
23
24
|
SOURCE_PATH,
|
|
24
25
|
PREFIX_RELATIONSHIP,
|
|
25
26
|
PROPERTY_VALUE_TAG,
|
|
26
|
-
SAVE_FILE_NAME
|
|
27
|
+
SAVE_FILE_NAME,
|
|
28
|
+
STORAGE_TYPES
|
|
27
29
|
} = require('../../../../MainLibs/src/Consts');
|
|
28
30
|
|
|
29
31
|
const templatePath = path.join(__dirname, "./tempRelationship.ejs");
|
|
@@ -87,7 +89,14 @@ function createSourceParams(_izContext, objectSchema, settings, srcPath) {
|
|
|
87
89
|
const attributeRelationships = [];
|
|
88
90
|
// const objectType = objectSchema.objectType; // main objectType
|
|
89
91
|
let propertyValue = settings.propertyValueTag
|
|
90
|
-
const storageResources = objectSchema.storageResources // storageResource from main objectType
|
|
92
|
+
const storageResources = objectSchema.storageResources; // storageResource from main objectType
|
|
93
|
+
let cloneDeepStorageResources = lodash.cloneDeep(storageResources)
|
|
94
|
+
for (let [storageResourceTag, storageResourceSetting] of Object.entries(cloneDeepStorageResources)) {
|
|
95
|
+
if (storageResourceSetting.storageType === STORAGE_TYPES.dynamoDB) {
|
|
96
|
+
delete cloneDeepStorageResources[storageResourceTag]
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
91
100
|
const serviceTag = getLocalConfig(path.join(srcPath, "../"), "iz_serviceTag")
|
|
92
101
|
attributeRelationships.push(
|
|
93
102
|
{ // has{objectType}propertyValue
|
|
@@ -105,7 +114,7 @@ function createSourceParams(_izContext, objectSchema, settings, srcPath) {
|
|
|
105
114
|
linkType: "many",
|
|
106
115
|
requiredOnCreate: true
|
|
107
116
|
},
|
|
108
|
-
|
|
117
|
+
cloneDeepStorageResources,
|
|
109
118
|
"from"
|
|
110
119
|
)
|
|
111
120
|
},
|
|
@@ -125,7 +134,7 @@ function createSourceParams(_izContext, objectSchema, settings, srcPath) {
|
|
|
125
134
|
linkType: "many",
|
|
126
135
|
requiredOnCreate: false
|
|
127
136
|
},
|
|
128
|
-
|
|
137
|
+
cloneDeepStorageResources,
|
|
129
138
|
"from"
|
|
130
139
|
)
|
|
131
140
|
},
|
|
@@ -145,7 +154,7 @@ function createSourceParams(_izContext, objectSchema, settings, srcPath) {
|
|
|
145
154
|
linkType: "one",
|
|
146
155
|
requiredOnCreate: false
|
|
147
156
|
},
|
|
148
|
-
|
|
157
|
+
cloneDeepStorageResources,
|
|
149
158
|
"from"
|
|
150
159
|
)
|
|
151
160
|
}
|
|
@@ -0,0 +1,123 @@
|
|
|
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 path = require('path');
|
|
20
|
+
|
|
21
|
+
const { ACTIONS, HANDLER, STORAGE_TYPES } = require('@izara_project/izara-core-library-service-schemas/src/Consts');
|
|
22
|
+
|
|
23
|
+
const { firstLetterLowerCase: lowerCase, firstLetterUpperCase: upperCase } = require("../../../../../../../MainLibs/index.js").utils;
|
|
24
|
+
const {
|
|
25
|
+
createIamRole,
|
|
26
|
+
resourceNames,
|
|
27
|
+
RESOURCE_CLASSES,
|
|
28
|
+
SOURCE_PATH,
|
|
29
|
+
SAVE_FILE_NAME,
|
|
30
|
+
FUNCTION_NAME,
|
|
31
|
+
SNS_RESOURCE,
|
|
32
|
+
defaultIamRolePerAction,
|
|
33
|
+
awaitingMultipleStepsRole,
|
|
34
|
+
shortNameHandler,
|
|
35
|
+
SHORT_FUNCTION_NAME,
|
|
36
|
+
SOURCE_GENERATE_IAM_ROLE,
|
|
37
|
+
checkDynamoTypeRelationship,
|
|
38
|
+
createDynamoDbComponentByLinks,
|
|
39
|
+
DYNAMO_RESOURCE,
|
|
40
|
+
SQS_RESOURCE
|
|
41
|
+
} = require("../../../../../../../MainLibs/src/Consts.js");
|
|
42
|
+
|
|
43
|
+
const templatePath = path.join(__dirname, "./template.ejs")
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* receive objectSchema
|
|
47
|
+
* create data for updateRelationshipSchema
|
|
48
|
+
*
|
|
49
|
+
* @param {Object} objectSchema
|
|
50
|
+
* @return {{ templatePath, templateData, setting } }
|
|
51
|
+
*/
|
|
52
|
+
|
|
53
|
+
function data(_izContext, allObjectRelationships, srcPath) {
|
|
54
|
+
let createSourceArray = [];
|
|
55
|
+
|
|
56
|
+
const createSourceParam = createParamForCreateSource(allObjectRelationships, srcPath);
|
|
57
|
+
createSourceArray.push(createSourceParam);
|
|
58
|
+
// console.log("createSourceArrayInUpdaterelationShipSchemahdrSqs", createSourceArray)
|
|
59
|
+
return createSourceArray
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
function createParamForCreateSource(allObjectRelationships, srcPath) {
|
|
64
|
+
|
|
65
|
+
let handlerType = HANDLER.hdrApi
|
|
66
|
+
let functionName = FUNCTION_NAME.changeRel
|
|
67
|
+
let additionalResourcePermission = defaultIamRolePerAction();
|
|
68
|
+
|
|
69
|
+
additionalResourcePermission.push(awaitingMultipleStepsRole())
|
|
70
|
+
|
|
71
|
+
additionalResourcePermission.push(
|
|
72
|
+
createIamRole(
|
|
73
|
+
{
|
|
74
|
+
[RESOURCE_CLASSES.sqs]: [
|
|
75
|
+
SQS_RESOURCE.deleteMessage,
|
|
76
|
+
SQS_RESOURCE.getQueueAttributes,
|
|
77
|
+
SQS_RESOURCE.receiveMessage,
|
|
78
|
+
SQS_RESOURCE.sendMessage,
|
|
79
|
+
SQS_RESOURCE.getQueueUrl,
|
|
80
|
+
SQS_RESOURCE.deleteMessageBatch
|
|
81
|
+
],
|
|
82
|
+
},
|
|
83
|
+
[
|
|
84
|
+
resourceNames(RESOURCE_CLASSES.sqs, upperCase(functionName) + upperCase(HANDLER.hdrSqs)),
|
|
85
|
+
resourceNames(RESOURCE_CLASSES.sqs, upperCase(functionName) + upperCase(HANDLER.hdrSqs) + "DLQ"),
|
|
86
|
+
resourceNames(RESOURCE_CLASSES.sqs, upperCase(functionName) + upperCase(HANDLER.hdrDsq)),
|
|
87
|
+
resourceNames(RESOURCE_CLASSES.sqs, upperCase(functionName) + upperCase(HANDLER.hdrDsq) + "DLQ"),
|
|
88
|
+
]
|
|
89
|
+
),
|
|
90
|
+
createIamRole(
|
|
91
|
+
{
|
|
92
|
+
[RESOURCE_CLASSES.sns]: [SNS_RESOURCE.publish, SNS_RESOURCE.subscribe]
|
|
93
|
+
},
|
|
94
|
+
[
|
|
95
|
+
resourceNames(RESOURCE_CLASSES.sns, upperCase(FUNCTION_NAME.changeRelComplete) + "_Out"),
|
|
96
|
+
resourceNames(RESOURCE_CLASSES.sns, upperCase(functionName) + "_In"),
|
|
97
|
+
resourceNames(RESOURCE_CLASSES.sns, upperCase(functionName) + "_Out"),
|
|
98
|
+
]
|
|
99
|
+
)
|
|
100
|
+
)
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
return {
|
|
104
|
+
templatePath: templatePath,
|
|
105
|
+
templateData: {
|
|
106
|
+
functionName,
|
|
107
|
+
handlerType,
|
|
108
|
+
additionalResourcePermission,
|
|
109
|
+
resourceLocation: SOURCE_PATH.resourceLocationRelationshipPerAction,
|
|
110
|
+
functionNameConfig: upperCase(SHORT_FUNCTION_NAME.changeRel) + upperCase(shortNameHandler(handlerType)),
|
|
111
|
+
roleName: SOURCE_GENERATE_IAM_ROLE.RelationshipRole
|
|
112
|
+
},
|
|
113
|
+
setting: {
|
|
114
|
+
savePath: path.join(srcPath, SOURCE_PATH.appYaml),
|
|
115
|
+
saveFileName: SAVE_FILE_NAME.functionRelationshipYaml,
|
|
116
|
+
fileExtension: '.yml',
|
|
117
|
+
isAppend: true
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
module.exports = data;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
<%_ const join = require('path').join; _%>
|
|
2
|
+
<%- firstLetterUpperCase(functionNameConfig) %>:
|
|
3
|
+
handler: <%- join(resourceLocation, `${firstLetterUpperCase(functionName)}_${firstLetterUpperCase(handlerType)}.main`)%>
|
|
4
|
+
name: ${self:custom.iz_resourcePrefix}<%- firstLetterUpperCase(functionName) %><%- firstLetterUpperCase(handlerType) %>
|
|
5
|
+
events:
|
|
6
|
+
- http:
|
|
7
|
+
path: <%- firstLetterUpperCase(functionName) %><%- firstLetterUpperCase(handlerType) %>
|
|
8
|
+
method: put
|
|
9
|
+
cors: true
|
|
10
|
+
#<#Authorizer#>
|
|
11
|
+
#<#/Authorizer#>
|
|
12
|
+
role: <%- roleName %>Role
|
|
13
|
+
#<#<%- functionName %><%- firstLetterUpperCase(handlerType) %>IamRole#>
|
|
14
|
+
#<#/<%- functionName %><%- firstLetterUpperCase(handlerType) %>IamRole#>
|
|
15
|
+
<%_ function firstLetterUpperCase(text){
|
|
16
|
+
return text.charAt(0).toUpperCase() + text.slice(1)
|
|
17
|
+
} _%>
|
|
18
|
+
<%_ function firstLetterLowerCase(str) {
|
|
19
|
+
return str.charAt(0).toLowerCase() + str.slice(1)
|
|
20
|
+
} _%>
|
|
@@ -0,0 +1,122 @@
|
|
|
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 path = require('path');
|
|
20
|
+
|
|
21
|
+
const { ACTIONS, HANDLER, STORAGE_TYPES } = require('@izara_project/izara-core-library-service-schemas/src/Consts')
|
|
22
|
+
|
|
23
|
+
const { firstLetterLowerCase: lowerCase, firstLetterUpperCase: upperCase } = require("../../../../../../../MainLibs/index.js").utils;
|
|
24
|
+
const {
|
|
25
|
+
createIamRole,
|
|
26
|
+
resourceNames,
|
|
27
|
+
RESOURCE_CLASSES,
|
|
28
|
+
SQS_RESOURCE,
|
|
29
|
+
SOURCE_PATH,
|
|
30
|
+
SAVE_FILE_NAME,
|
|
31
|
+
FUNCTION_NAME,
|
|
32
|
+
SNS_RESOURCE,
|
|
33
|
+
defaultIamRolePerAction,
|
|
34
|
+
awaitingMultipleStepsRole,
|
|
35
|
+
shortNameHandler,
|
|
36
|
+
SHORT_FUNCTION_NAME,
|
|
37
|
+
SOURCE_GENERATE_IAM_ROLE,
|
|
38
|
+
checkDynamoTypeRelationship,
|
|
39
|
+
createDynamoDbComponentByLinks,
|
|
40
|
+
DYNAMO_RESOURCE
|
|
41
|
+
} = require("../../../../../../../MainLibs/src/Consts");
|
|
42
|
+
|
|
43
|
+
const templatePath = path.join(__dirname, './template.ejs')
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* receive objectSchema
|
|
47
|
+
* create data for updateRelationshipSchema
|
|
48
|
+
*
|
|
49
|
+
* @param {Object} objectSchema
|
|
50
|
+
* @return {{ templatePath, templateData, setting } }
|
|
51
|
+
*/
|
|
52
|
+
|
|
53
|
+
function data(_izContext, allObjectRelationships, srcPath) {
|
|
54
|
+
let createSourceArray = [];
|
|
55
|
+
|
|
56
|
+
const createSourceParam = createParamForCreateSource(allObjectRelationships, srcPath);
|
|
57
|
+
createSourceArray.push(createSourceParam);
|
|
58
|
+
// console.log("createSourceArrayInUpdaterelationShipSchemahdrSqs", createSourceArray)
|
|
59
|
+
return createSourceArray
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
function createParamForCreateSource(allObjectRelationships, srcPath) {
|
|
64
|
+
|
|
65
|
+
let handlerType = HANDLER.hdrDsq
|
|
66
|
+
let functionName = FUNCTION_NAME.changeRel
|
|
67
|
+
let additionalResourcePermission = defaultIamRolePerAction();
|
|
68
|
+
|
|
69
|
+
additionalResourcePermission.push(
|
|
70
|
+
createIamRole(
|
|
71
|
+
{
|
|
72
|
+
[RESOURCE_CLASSES.sqs]: [
|
|
73
|
+
SQS_RESOURCE.deleteMessage,
|
|
74
|
+
SQS_RESOURCE.getQueueAttributes,
|
|
75
|
+
SQS_RESOURCE.receiveMessage,
|
|
76
|
+
SQS_RESOURCE.sendMessage,
|
|
77
|
+
SQS_RESOURCE.getQueueUrl,
|
|
78
|
+
SQS_RESOURCE.deleteMessageBatch
|
|
79
|
+
],
|
|
80
|
+
},
|
|
81
|
+
[
|
|
82
|
+
resourceNames(RESOURCE_CLASSES.sqs, upperCase(functionName) + upperCase(HANDLER.hdrSqs)),
|
|
83
|
+
resourceNames(RESOURCE_CLASSES.sqs, upperCase(functionName) + upperCase(HANDLER.hdrSqs) + "DLQ"),
|
|
84
|
+
resourceNames(RESOURCE_CLASSES.sqs, upperCase(functionName) + upperCase(HANDLER.hdrDsq)),
|
|
85
|
+
resourceNames(RESOURCE_CLASSES.sqs, upperCase(functionName) + upperCase(HANDLER.hdrDsq) + "DLQ"),
|
|
86
|
+
]
|
|
87
|
+
),
|
|
88
|
+
createIamRole(
|
|
89
|
+
{
|
|
90
|
+
[RESOURCE_CLASSES.sns]: [SNS_RESOURCE.publish, SNS_RESOURCE.subscribe]
|
|
91
|
+
},
|
|
92
|
+
[
|
|
93
|
+
resourceNames(RESOURCE_CLASSES.sns, upperCase(FUNCTION_NAME.changeRelComplete) + "_Out"),
|
|
94
|
+
resourceNames(RESOURCE_CLASSES.sns, upperCase(functionName) + "_In"),
|
|
95
|
+
resourceNames(RESOURCE_CLASSES.sns, upperCase(functionName) + "_Out"),
|
|
96
|
+
]
|
|
97
|
+
)
|
|
98
|
+
)
|
|
99
|
+
|
|
100
|
+
additionalResourcePermission.push(awaitingMultipleStepsRole())
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
return {
|
|
104
|
+
templatePath: templatePath,
|
|
105
|
+
templateData: {
|
|
106
|
+
functionName,
|
|
107
|
+
handlerType,
|
|
108
|
+
additionalResourcePermission,
|
|
109
|
+
resourceLocation: SOURCE_PATH.resourceLocationRelationshipPerAction,
|
|
110
|
+
functionNameConfig: upperCase(SHORT_FUNCTION_NAME.changeRel) + upperCase(shortNameHandler(handlerType)),
|
|
111
|
+
roleName: SOURCE_GENERATE_IAM_ROLE.RelationshipRole
|
|
112
|
+
},
|
|
113
|
+
setting: {
|
|
114
|
+
savePath: path.join(srcPath, SOURCE_PATH.appYaml),
|
|
115
|
+
saveFileName: SAVE_FILE_NAME.functionRelationshipYaml,
|
|
116
|
+
fileExtension: '.yml',
|
|
117
|
+
isAppend: true
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
module.exports = data;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
<%_ const join = require('path').join; _%>
|
|
2
|
+
<%- firstLetterUpperCase(functionNameConfig) %>:
|
|
3
|
+
handler: <%- join(resourceLocation, `${firstLetterUpperCase(functionName)}_${firstLetterUpperCase(handlerType)}.main`)%>
|
|
4
|
+
name: ${self:custom.iz_resourcePrefix}<%- firstLetterUpperCase(functionName) %><%- firstLetterUpperCase(handlerType) %>
|
|
5
|
+
events:
|
|
6
|
+
- sqs:
|
|
7
|
+
arn: arn:aws:sqs:${self:custom.iz_region}:${self:custom.iz_accountId}:${self:custom.iz_resourcePrefix}<%- firstLetterUpperCase(functionName) %><%- firstLetterUpperCase(handlerType) %>
|
|
8
|
+
batchSize: 10
|
|
9
|
+
role: <%- roleName %>Role
|
|
10
|
+
#<#<%- functionName %><%- firstLetterUpperCase(handlerType) %>IamRole#>
|
|
11
|
+
#<#/<%- functionName %><%- firstLetterUpperCase(handlerType) %>IamRole#>
|
|
12
|
+
<%_ function firstLetterUpperCase(text){
|
|
13
|
+
return text.charAt(0).toUpperCase() + text.slice(1)
|
|
14
|
+
} _%>
|
|
15
|
+
<%_ function firstLetterLowerCase(str) {
|
|
16
|
+
return str.charAt(0).toLowerCase() + str.slice(1)
|
|
17
|
+
} _%>
|