@izara_project/izara-market-library-service-schemas 1.0.37 → 1.0.39
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/GenerateCodeLibs.js +35 -5
- package/src/MainLibs/src/Consts.js +5 -2
- package/src/MainLibs/src/GenerateCodeUtils.js +2 -0
- package/src/MainLibs/src/Utils.js +12 -0
- package/src/reStructure/GenerateCode.js +2 -2
- package/src/reStructure/TemplateData/EndpointPerService/mainFunction/create/template.ejs +36 -11
- package/src/reStructure/TemplateData/EndpointPerService/mainFunction/delete/template.ejs +24 -1
- package/src/reStructure/TemplateData/EndpointPerService/mainFunction/get/template.ejs +26 -0
- package/src/reStructure/TemplateData/EndpointPerService/mainFunction/update/template.ejs +22 -0
- package/src/reStructure/TemplateData/EndpointPerService/yaml/data.js +37 -7
- package/src/reStructure/TemplateData/findData/handler/template.ejs +2 -2
- package/src/reStructure/TemplateData/flowSchema/components/upload/confirmReserved/mainFunction/template.ejs +2 -0
- package/src/reStructure/TemplateData/flowSchema/components/upload/createObject/mainFunction/template.ejs +5 -1
- package/src/reStructure/TemplateData/flowSchema/components/upload/createObjectComplete/sns-sqs/data.js +1 -1
- package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/reservedLimit/sqs/data.js +3 -3
- package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/reservedLimit/sqs/template.ejs +1 -1
- package/src/reStructure/TemplateData/flowSchema/components/upload/relate/libs/template.ejs +1 -1
- package/src/reStructure/TemplateData/flowSchema/components/websocket/connect/functionYaml/data.js +1 -1
- package/src/reStructure/TemplateData/flowSchema/components/websocket/connect/handler/data.js +1 -1
- package/src/reStructure/TemplateData/flowSchema/externalTopic/functionYaml/data.js +127 -0
- package/src/reStructure/TemplateData/flowSchema/externalTopic/handler/data.js +121 -0
- package/src/reStructure/TemplateData/flowSchema/externalTopic/{sqs/handler → handler}/template.ejs +16 -61
- package/src/reStructure/TemplateData/flowSchema/externalTopic/mainFunction/data.js +74 -0
- package/src/reStructure/TemplateData/flowSchema/externalTopic/mainFunction/template.ejs +131 -0
- package/src/reStructure/TemplateData/flowSchema/externalTopic/sns-in-sqs/data.js +61 -34
- package/src/reStructure/TemplateData/flowSchema/externalTopic/sns-in-sqs/template.ejs +1 -1
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComponent/functionYaml/data.js +3 -7
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComponent/handler/data.js +2 -5
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComponent/mainFunction/data.js +13 -4
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComponent/mainFunction/template.ejs +16 -37
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaComponent/functionYaml/data.js +2 -4
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaComponent/mainFunction/data.js +2 -5
- package/src/reStructure/TemplateData/flowSchema/{externalTopic/sqs → flowSchemaOwnTopic/flowStep}/functionYaml/data.js +43 -38
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/flowStep/functionYaml/template.ejs +20 -0
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/flowStep/handler/data.js +80 -0
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/flowStep/handler/template.ejs +85 -0
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/flowStep/mainFunction/data.js +92 -0
- package/src/reStructure/TemplateData/flowSchema/{externalTopic/websocket → flowSchemaOwnTopic/flowStep}/mainFunction/template.ejs +11 -13
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/sns-in/data.js +47 -37
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/sns-out/data.js +23 -26
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/{FlowSchemaCompleteComponent → webSocketComplete}/functionYaml/data.js +5 -21
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/webSocketComplete/functionYaml/template.ejs +20 -0
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/{FlowSchemaCompleteComponent → webSocketComplete}/handler/data.js +2 -2
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/{FlowSchemaCompleteComponent → webSocketComplete}/mainFunction/data.js +2 -2
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/{FlowSchemaCompleteComponent → webSocketComplete}/mainFunction/template.ejs +24 -10
- package/src/reStructure/TemplateData/flowSchema/generateTemplateData.js +32 -34
- package/src/reStructure/TemplateData/flowSchema/{createRecordByStatusType → register}/complete/handler/template.ejs +1 -1
- package/src/reStructure/TemplateData/flowSchema/register/complete/mainFunction/template.ejs +172 -0
- package/src/reStructure/TemplateData/flowSchema/register/wbs/mainFunction/template.ejs +165 -0
- package/src/reStructure/TemplateData/flowSchema/{createRecordByStatusType → templateBystatusType}/statusFieldTemplate.ejs +0 -5
- package/src/reStructure/TemplateData/flowSchema/templateBystatusType/storedCacheTemplate.ejs +24 -0
- package/src/reStructure/TemplateData/flowSchema/templateBystatusType/triggerCacheTemplate.ejs +20 -0
- package/src/reStructure/TemplateData/perActionComplete/get/mainFunction/template.ejs +3 -0
- package/src/reStructure/TemplateData/perActionComplete/update/mainFunction/template.ejs +3 -0
- package/src/reStructure/TemplateData/propertyValueSchema/relationshipPropertyValueSchema/data.js +2 -7
- package/src/reStructure/TemplateData/relationshipPerAction/create/action/functionYaml/api/data.js +22 -3
- package/src/reStructure/TemplateData/relationshipPerAction/create/action/functionYaml/dsq/data.js +14 -9
- package/src/reStructure/TemplateData/relationshipPerAction/create/action/functionYaml/inv/data.js +26 -6
- package/src/reStructure/TemplateData/relationshipPerAction/create/action/functionYaml/sqs/data.js +11 -7
- package/src/reStructure/TemplateData/relationshipPerAction/create/complete/functionYaml/data.js +17 -7
- package/src/reStructure/TemplateData/relationshipPerAction/delete/action/functionYaml/api/data.js +23 -4
- package/src/reStructure/TemplateData/relationshipPerAction/delete/action/functionYaml/dsq/data.js +14 -9
- package/src/reStructure/TemplateData/relationshipPerAction/delete/action/functionYaml/inv/data.js +26 -6
- package/src/reStructure/TemplateData/relationshipPerAction/delete/action/functionYaml/sqs/data.js +10 -7
- package/src/reStructure/TemplateData/relationshipPerAction/delete/complete/functionYaml/data.js +11 -7
- package/src/reStructure/TemplateData/relationshipPerAction/get/action/functionYaml/api/data.js +23 -4
- package/src/reStructure/TemplateData/relationshipPerAction/get/action/functionYaml/dsq/data.js +14 -9
- package/src/reStructure/TemplateData/relationshipPerAction/get/action/functionYaml/inv/data.js +26 -7
- package/src/reStructure/TemplateData/relationshipPerAction/get/action/functionYaml/sqs/data.js +10 -7
- package/src/reStructure/TemplateData/relationshipPerAction/get/complete/functionYaml/data.js +12 -7
- package/src/reStructure/TemplateData/relationshipPerAction/update/action/functionYaml/api/data.js +22 -3
- package/src/reStructure/TemplateData/relationshipPerAction/update/action/functionYaml/dsq/data.js +14 -6
- package/src/reStructure/TemplateData/relationshipPerAction/update/action/functionYaml/inv/data.js +20 -3
- package/src/reStructure/TemplateData/relationshipPerAction/update/action/functionYaml/sqs/data.js +9 -3
- package/src/reStructure/TemplateData/relationshipPerAction/update/complete/functionYaml/data.js +12 -6
- package/src/reStructure/TemplateData/resourceYaml/dynamodb/mainResourcePerObjectSchemaData.js +6 -2
- package/src/reStructure/TemplateData/resourceYaml/filterGenerateResource/data.js +20 -11
- package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/complete/mainFunction/template.ejs +0 -184
- package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/storedCacheTemplate.ejs +0 -11
- package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/wbs/mainFunction/template.ejs +0 -210
- package/src/reStructure/TemplateData/flowSchema/externalTopic/sns-out/data.js +0 -77
- package/src/reStructure/TemplateData/flowSchema/externalTopic/sns-out/template.ejs +0 -8
- package/src/reStructure/TemplateData/flowSchema/externalTopic/sqs/functionYaml/template.ejs +0 -17
- package/src/reStructure/TemplateData/flowSchema/externalTopic/sqs/handler/data.js +0 -64
- package/src/reStructure/TemplateData/flowSchema/externalTopic/sqs/mainFunction/data.js +0 -61
- package/src/reStructure/TemplateData/flowSchema/externalTopic/sqs/mainFunction/template.ejs +0 -74
- package/src/reStructure/TemplateData/flowSchema/externalTopic/websocket/functionYaml/data.js +0 -110
- package/src/reStructure/TemplateData/flowSchema/externalTopic/websocket/functionYaml/template.ejs +0 -18
- package/src/reStructure/TemplateData/flowSchema/externalTopic/websocket/handler/data.js +0 -57
- package/src/reStructure/TemplateData/flowSchema/externalTopic/websocket/handler/template.ejs +0 -85
- package/src/reStructure/TemplateData/flowSchema/externalTopic/websocket/mainFunction/data.js +0 -67
- /package/src/reStructure/TemplateData/flowSchema/{flowSchemaOwnTopic/FlowSchemaCompleteComponent → externalTopic}/functionYaml/template.ejs +0 -0
- /package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/{FlowSchemaCompleteComponent → webSocketComplete}/handler/template.ejs +0 -0
- /package/src/reStructure/TemplateData/flowSchema/{createRecordByStatusType → register}/complete/functionYaml/data.js +0 -0
- /package/src/reStructure/TemplateData/flowSchema/{createRecordByStatusType → register}/complete/functionYaml/template.ejs +0 -0
- /package/src/reStructure/TemplateData/flowSchema/{createRecordByStatusType → register}/complete/handler/data.js +0 -0
- /package/src/reStructure/TemplateData/flowSchema/{createRecordByStatusType → register}/complete/mainFunction/data.js +0 -0
- /package/src/reStructure/TemplateData/flowSchema/{createRecordByStatusType → register}/dynamoDB/register.js +0 -0
- /package/src/reStructure/TemplateData/flowSchema/{createRecordByStatusType → register}/sns-in/data.js +0 -0
- /package/src/reStructure/TemplateData/flowSchema/{createRecordByStatusType → register}/sns-in/template.ejs +0 -0
- /package/src/reStructure/TemplateData/flowSchema/{createRecordByStatusType → register}/subscriptionOutAll/data.js +0 -0
- /package/src/reStructure/TemplateData/flowSchema/{createRecordByStatusType → register}/subscriptionOutAll/template.ejs +0 -0
- /package/src/reStructure/TemplateData/flowSchema/{createRecordByStatusType → register}/wbs/functionYaml/data.js +0 -0
- /package/src/reStructure/TemplateData/flowSchema/{createRecordByStatusType → register}/wbs/functionYaml/template.ejs +0 -0
- /package/src/reStructure/TemplateData/flowSchema/{createRecordByStatusType → register}/wbs/handler/data.js +0 -0
- /package/src/reStructure/TemplateData/flowSchema/{createRecordByStatusType → register}/wbs/handler/template.ejs +0 -0
- /package/src/reStructure/TemplateData/flowSchema/{createRecordByStatusType → register}/wbs/mainFunction/data.js +0 -0
|
@@ -37,18 +37,13 @@ const { NoRetryError } = require("@izara_project/izara-core-library-core");
|
|
|
37
37
|
async function filterCreateResourceYaml(_izContext, createSourceParams, objSchemaPath) {
|
|
38
38
|
let tableNamesToFilter = new Set();
|
|
39
39
|
const allLocalFlowSchema = await getObjectSchema.getAllLocalFlowSchemas(_izContext, objSchemaPath);
|
|
40
|
-
|
|
40
|
+
await Promise.all(allLocalFlowSchema.records.map(async (flowSchema) => {
|
|
41
41
|
if (flowSchema.statusType === "storedCache") {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
tableNamesToFilter.add(storageResource.tableName);
|
|
46
|
-
}
|
|
47
|
-
} else {
|
|
48
|
-
throw new NoRetryError('not have objectSchema in service to get')
|
|
49
|
-
}
|
|
42
|
+
tableNamesToFilter.add(...await getStoredCacheTableFromFlowSchema(_izContext, flowSchema))
|
|
43
|
+
} else if (flowSchema.statusType === "triggerCache" && flowSchema?.triggerType === "storedCache") {
|
|
44
|
+
tableNamesToFilter.add(...await getStoredCacheTableFromFlowSchema(_izContext, flowSchema))
|
|
50
45
|
}
|
|
51
|
-
}
|
|
46
|
+
}))
|
|
52
47
|
|
|
53
48
|
const filteredCreateSourceParams = createSourceParams.filter(
|
|
54
49
|
(result) => !tableNamesToFilter.has(result.templateData.tableName)
|
|
@@ -58,4 +53,18 @@ async function filterCreateResourceYaml(_izContext, createSourceParams, objSchem
|
|
|
58
53
|
return filteredCreateSourceParams
|
|
59
54
|
}
|
|
60
55
|
|
|
61
|
-
module.exports = filterCreateResourceYaml;
|
|
56
|
+
module.exports = filterCreateResourceYaml;
|
|
57
|
+
|
|
58
|
+
async function getStoredCacheTableFromFlowSchema(_izContext, flowSchema) {
|
|
59
|
+
let tableNameStoredCache = new Set();
|
|
60
|
+
const objectSchema = await getObjectSchema.getLocalObjectSchemas(_izContext, [flowSchema.objType.objectType], objSchemaPath).then(res => res.records[0])
|
|
61
|
+
if (objectSchema) {
|
|
62
|
+
for (const storageResource of Object.values(objectSchema.storageResources)) {
|
|
63
|
+
if (storageResource.storageType === STORAGE_TYPES.dynamoDB) {
|
|
64
|
+
tableNameStoredCache.add(storageResource.tableName);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
} else {
|
|
68
|
+
throw new NoRetryError('not have objectSchema in service to get')
|
|
69
|
+
}
|
|
70
|
+
}
|
|
@@ -1,184 +0,0 @@
|
|
|
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
|
|
16
|
-
<http: //www.gnu.org/licenses />.
|
|
17
|
-
*/
|
|
18
|
-
|
|
19
|
-
'use strict';
|
|
20
|
-
|
|
21
|
-
const hash = require('@izara_project/izara-shared-core').objectHash;
|
|
22
|
-
const { getObjectSchema } = require('@izara_project/izara-core-library-service-schemas');
|
|
23
|
-
|
|
24
|
-
const dynamodbSharedLib = require('@izara_project/izara-core-library-dynamodb');
|
|
25
|
-
const snsSharedLib = require('@izara_project/izara-core-library-sns');
|
|
26
|
-
const asyncFlowSharedLib = require('@izara_project/izara-core-library-asynchronous-flow');
|
|
27
|
-
const callingFlowSharedLib = require('@izara_project/izara-core-library-calling-flow');
|
|
28
|
-
const lambdaSharedLib = require('@izara_project/izara-core-library-lambda');
|
|
29
|
-
|
|
30
|
-
const externalRequest = require('@izara_project/izara-core-library-external-request');
|
|
31
|
-
const sns = externalRequest.sns
|
|
32
|
-
const { postToConnection } = require("../../../libs/source/GenerateCodeLibs");
|
|
33
|
-
|
|
34
|
-
const utils = require('@izara_project/izara-market-library-service-schemas/src/MainLibs/src/Utils')
|
|
35
|
-
const { NoRetryError } = require('@izara_project/izara-core-library-core')
|
|
36
|
-
const { v4: uuidv4 } = require('uuid')
|
|
37
|
-
const coreConsts = require("@izara_project/izara-core-library-core/src/Consts");
|
|
38
|
-
// const { TOPIC_NAME_GENERATE_CODE } = require('@izara_project/izara-market-library-service-schemas/src/GenerateCodeLibs/src/Consts')
|
|
39
|
-
const { generateCodeLibs: { consts: TOPIC_NAME_GENERATE_CODE } } = require('@izara_project/izara-market-library-service-schemas')
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* description of function.
|
|
43
|
-
* @param {Object} _izContext
|
|
44
|
-
* @param {CorrelationIds} _izContext.correlationIds - property of _izContext
|
|
45
|
-
* @param {Logger} _izContext.logger - property of _izContext
|
|
46
|
-
* @param {Object} requestParams - request params
|
|
47
|
-
* @param {Object} requestParams.identifiers - identifiers for get data
|
|
48
|
-
* @param {Object} requestParams.additionalRequest - additionalRequest
|
|
49
|
-
*
|
|
50
|
-
* @returns {object} description of return value
|
|
51
|
-
*/
|
|
52
|
-
module.exports.registerCompleteMain = async (
|
|
53
|
-
_izContext,
|
|
54
|
-
requestParams,
|
|
55
|
-
callingFlowConfig = {},
|
|
56
|
-
//(<additionalParams>)
|
|
57
|
-
//(</additionalParams>)
|
|
58
|
-
) => {
|
|
59
|
-
try {
|
|
60
|
-
_izContext.logger.debug("WebSocketInvoke _izContext", _izContext)
|
|
61
|
-
_izContext.logger.debug("WebSocketInvoke requestParams", requestParams)
|
|
62
|
-
_izContext.logger.debug("WebSocketInvoke callingFlowConfig", callingFlowConfig)
|
|
63
|
-
|
|
64
|
-
const connectionId = requestContext.connectionId;
|
|
65
|
-
let correlationId = _izContext.correlationIds.get(consts.X_CORRELATION_ID);
|
|
66
|
-
|
|
67
|
-
const getRegisterRecords = await dynamodbSharedLib.getItem(
|
|
68
|
-
_izContext,
|
|
69
|
-
await dynamodbSharedLib.tableName(_izContext, "RegisterRecords"),
|
|
70
|
-
{
|
|
71
|
-
identifierTask: correlationId,
|
|
72
|
-
connectionId: connectionId,
|
|
73
|
-
}
|
|
74
|
-
);
|
|
75
|
-
_izContext.logger.debug("getRegisterRecords", getRegisterRecords)
|
|
76
|
-
if (!getRegisterRecords) {
|
|
77
|
-
throw new NoRetryError(`connectionId not found ${connectionId}`)
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
const flowType = getRegisterRecords.flowType;
|
|
81
|
-
const flowTag = flowType.split('_')[0];
|
|
82
|
-
const getFlowSchema = await getObjectSchema.getFlowSchemaS3WithCache(_izContext, {
|
|
83
|
-
flowTag: flowTag,
|
|
84
|
-
serviceTag: process.env.iz_serviceTag
|
|
85
|
-
})
|
|
86
|
-
_izContext.logger.debug("getFlowSchema", getFlowSchema)
|
|
87
|
-
if (!getFlowSchema) {
|
|
88
|
-
throw new NoRetryError(`flowTag not found ${flowTag}`)
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
// get data from dynamoDB of objectType of flowSchema
|
|
92
|
-
const getStoredCache = async (objectType) => {
|
|
93
|
-
const objectSchema = await getObjectSchema.getObjSchemaS3WithCache(
|
|
94
|
-
_izContext,
|
|
95
|
-
{
|
|
96
|
-
objectType: objectType,
|
|
97
|
-
serviceTag: process.env.iz_serviceTag,
|
|
98
|
-
})
|
|
99
|
-
|
|
100
|
-
_izContext.logger.debug("==> objectSchema", objectSchema)
|
|
101
|
-
|
|
102
|
-
// this returns the table name of the first storage resource with storageType "dynamoDB"
|
|
103
|
-
const tableName = Object.values(objectSchema.storageResources).find(
|
|
104
|
-
(storageResource) => storageResource.storageType === "dynamoDB"
|
|
105
|
-
)?.tableName
|
|
106
|
-
_izContext.logger.debug("==> tableName", tableName)
|
|
107
|
-
|
|
108
|
-
let identifierPK = null
|
|
109
|
-
let identifierSK = null
|
|
110
|
-
objectSchema.identifiers.map((identifier) => {
|
|
111
|
-
if (identifier.type === "partitionKey") {
|
|
112
|
-
identifierPK = identifier.fieldName
|
|
113
|
-
} else if (identifier.type === "sortKey") {
|
|
114
|
-
identifierSK = identifier.fieldName
|
|
115
|
-
}
|
|
116
|
-
})
|
|
117
|
-
|
|
118
|
-
_izContext.logger.debug("==> identifierPK", identifierPK)
|
|
119
|
-
_izContext.logger.debug("==> identifierSK", identifierSK)
|
|
120
|
-
|
|
121
|
-
const payloadGetStoredCache = {
|
|
122
|
-
[identifierPK]: requestParams.identifiers[identifierPK],
|
|
123
|
-
}
|
|
124
|
-
if (identifierSK) {
|
|
125
|
-
payloadGetStoredCache[identifierSK] = requestParams.identifiers[identifierSK]
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
_izContext.logger.debug("==> payloadGetStoredCache", payloadGetStoredCache)
|
|
129
|
-
|
|
130
|
-
// const getStoredCache = await dynamodbSharedLib.getItem(
|
|
131
|
-
// _izContext,
|
|
132
|
-
// await dynamodbSharedLib.tableName(_izContext, tableName),
|
|
133
|
-
// payloadGetStoredCache
|
|
134
|
-
// )
|
|
135
|
-
|
|
136
|
-
const getStoredCache = await dynamodbSharedLib.query(
|
|
137
|
-
_izContext,
|
|
138
|
-
await dynamodbSharedLib.tableName(_izContext, tableName),
|
|
139
|
-
payloadGetStoredCache
|
|
140
|
-
)
|
|
141
|
-
_izContext.logger.debug("==> getStoredCache:::", getStoredCache)
|
|
142
|
-
return ({
|
|
143
|
-
data: getStoredCache.Items[0],
|
|
144
|
-
identifierPK: identifierPK,
|
|
145
|
-
})
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
switch (getFlowSchema.statusType) {
|
|
149
|
-
case "statusField":
|
|
150
|
-
let payload = {
|
|
151
|
-
identifiers: requestParams.identifiers,
|
|
152
|
-
objectType: getFlowSchema.objType.objectType
|
|
153
|
-
}
|
|
154
|
-
let result = await externalRequest.lambda.invokeSync(
|
|
155
|
-
_izContext,
|
|
156
|
-
await lambdaSharedLib.lambdaFunctionName(_izContext, "GetHdrInv", getFlowSchema.objType.serviceTag),
|
|
157
|
-
payload
|
|
158
|
-
)
|
|
159
|
-
if (!result) {
|
|
160
|
-
throw new NoRetryError(`statusField not found ${requestParams.identifiers}`)
|
|
161
|
-
}
|
|
162
|
-
await postToConnection({message:result}, connectionId)
|
|
163
|
-
return result
|
|
164
|
-
case "storedCache":
|
|
165
|
-
// if statusType=storedCache then query storedCache > post message to client -> remove connectionId if status = error || complete
|
|
166
|
-
const resultStoredCache = resultStoredCache(getFlowSchema.objType.objectType)
|
|
167
|
-
|
|
168
|
-
if (!resultStoredCache) {
|
|
169
|
-
throw new NoRetryError(`storedCache not found ${requestParams.identifiers}`)
|
|
170
|
-
}
|
|
171
|
-
await postToConnection({message:resultStoredCache }, connectionId)
|
|
172
|
-
return resultStoredCache
|
|
173
|
-
case "none":
|
|
174
|
-
// if statusType=none -> post message to client ---- not remove connectionId when post message, can remove connectionId when cannot use connectionId only(user disconnect)
|
|
175
|
-
break
|
|
176
|
-
default:
|
|
177
|
-
throw new NoRetryError(`statusType not found ${getFlowSchema.statusType}`)
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
} catch (err) {
|
|
181
|
-
_izContext.logger.error('error WebSocketInvoke: ', err)
|
|
182
|
-
throw (err)
|
|
183
|
-
}
|
|
184
|
-
}
|
package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/storedCacheTemplate.ejs
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
let expiryTime = storedCacheSharedLib.createExpiryTime(_izContext, 31536000);
|
|
2
|
-
|
|
3
|
-
//(<createKeyValuesStoredCacheTable>)
|
|
4
|
-
//(</createKeyValuesStoredCacheTable>)
|
|
5
|
-
|
|
6
|
-
let [ cacheMainStauts, cacheId, cacheMain ] = await storedCacheSharedLib.checkStoredCacheStatus(
|
|
7
|
-
_izContext,
|
|
8
|
-
"<%- tableName %>",
|
|
9
|
-
//(<keyValueStoredCacheTable>)
|
|
10
|
-
//(</keyValueStoredCacheTable>)
|
|
11
|
-
)
|
|
@@ -1,210 +0,0 @@
|
|
|
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
|
|
16
|
-
<http: //www.gnu.org/licenses />.
|
|
17
|
-
*/
|
|
18
|
-
|
|
19
|
-
'use strict';
|
|
20
|
-
|
|
21
|
-
const hash = require('@izara_project/izara-shared-core').objectHash;
|
|
22
|
-
const { getObjectSchema } = require('@izara_project/izara-core-library-service-schemas');
|
|
23
|
-
|
|
24
|
-
const dynamodbSharedLib = require('@izara_project/izara-core-library-dynamodb');
|
|
25
|
-
const snsSharedLib = require('@izara_project/izara-core-library-sns');
|
|
26
|
-
const asyncFlowSharedLib = require('@izara_project/izara-core-library-asynchronous-flow');
|
|
27
|
-
const callingFlowSharedLib = require('@izara_project/izara-core-library-calling-flow');
|
|
28
|
-
const lambdaSharedLib = require('@izara_project/izara-core-library-lambda');
|
|
29
|
-
|
|
30
|
-
const externalRequest = require('@izara_project/izara-core-library-external-request');
|
|
31
|
-
const sns = externalRequest.sns
|
|
32
|
-
|
|
33
|
-
const utils = require('@izara_project/izara-market-library-service-schemas/src/MainLibs/src/Utils')
|
|
34
|
-
const NoRetryError = require('@izara_project/izara-core-library-core').NoRetryError
|
|
35
|
-
const { v4: uuidv4 } = require('uuid')
|
|
36
|
-
const consts = require('@izara_project/izara-middleware/src/MiddlewareCore/Consts')
|
|
37
|
-
const { TOPIC_NAME_GENERATE_CODE } = require('@izara_project/izara-market-library-service-schemas/src/GenerateCodeLibs/src/Consts')
|
|
38
|
-
const generatedCodeLibs = require('../../../libs/source/GenerateCodeLibs')
|
|
39
|
-
/**
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
* description of function.
|
|
43
|
-
* @param {Object} _izContext
|
|
44
|
-
* @param {CorrelationIds} _izContext.correlationIds - property of _izContext
|
|
45
|
-
* @param {Logger} _izContext.logger - property of _izContext
|
|
46
|
-
* @param {Object} requestParams - request params
|
|
47
|
-
* @param {Object} requestParams.identifiers - identifiers for get data
|
|
48
|
-
* @param {Object} requestParams.additionalRequest - additionalRequest
|
|
49
|
-
*
|
|
50
|
-
*
|
|
51
|
-
* @returns {object} description of return value
|
|
52
|
-
*/
|
|
53
|
-
|
|
54
|
-
module.exports.registerMain = async (
|
|
55
|
-
_izContext,
|
|
56
|
-
requestParams,
|
|
57
|
-
callingFlowConfig = {},
|
|
58
|
-
//(<additionalParams>)
|
|
59
|
-
//(</additionalParams>)
|
|
60
|
-
) => {
|
|
61
|
-
try {
|
|
62
|
-
let connecttionId = _izContext.correlationIds.get(consts.CONNECTION_ID)
|
|
63
|
-
// receive flowTag and identifiers
|
|
64
|
-
let flowSchema = await getObjectSchema.getFlowSchemaS3WithCache(_izContext, {
|
|
65
|
-
flowTag: requestParams.flowTag,
|
|
66
|
-
serviceTag: process.env.iz_serviceTag,
|
|
67
|
-
})
|
|
68
|
-
|
|
69
|
-
_izContext.logger.debug("flowSchema", flowSchema)
|
|
70
|
-
if (!flowSchema) {
|
|
71
|
-
throw new NoRetryError(`flowTag not found ${requestParams.flowTag}`)
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
// get data from dynamoDB of objectType of flowSchema
|
|
75
|
-
const getStoredCache = async (objectType) => {
|
|
76
|
-
const objectSchema = await getObjectSchema.getObjSchemaS3WithCache(
|
|
77
|
-
_izContext,
|
|
78
|
-
{
|
|
79
|
-
objectType: objectType,
|
|
80
|
-
serviceTag: process.env.iz_serviceTag,
|
|
81
|
-
})
|
|
82
|
-
|
|
83
|
-
_izContext.logger.debug("==> objectSchema", objectSchema)
|
|
84
|
-
|
|
85
|
-
// this returns the table name of the first storage resource with storageType "dynamoDB"
|
|
86
|
-
const tableName = Object.values(objectSchema.storageResources).find(
|
|
87
|
-
(storageResource) => storageResource.storageType === "dynamoDB"
|
|
88
|
-
)?.tableName
|
|
89
|
-
_izContext.logger.debug("==> tableName", tableName)
|
|
90
|
-
|
|
91
|
-
// const identifierPK = objectSchema[identifierPK].find(
|
|
92
|
-
// (identifier) => identifier.type === "partitionKey"
|
|
93
|
-
// )?.fieldName
|
|
94
|
-
|
|
95
|
-
// const identifierSK = objectSchema[identifierSK].find(
|
|
96
|
-
// (identifier) => identifier.type === "sortKey"
|
|
97
|
-
// )?.fieldName
|
|
98
|
-
|
|
99
|
-
let identifierPK = null
|
|
100
|
-
let identifierSK = null
|
|
101
|
-
objectSchema.identifiers.map((identifier) => {
|
|
102
|
-
if (identifier.type === "partitionKey") {
|
|
103
|
-
identifierPK = identifier.fieldName
|
|
104
|
-
} else if (identifier.type === "sortKey") {
|
|
105
|
-
identifierSK = identifier.fieldName
|
|
106
|
-
}
|
|
107
|
-
})
|
|
108
|
-
|
|
109
|
-
_izContext.logger.debug("==> identifierPK", identifierPK)
|
|
110
|
-
_izContext.logger.debug("==> identifierSK", identifierSK)
|
|
111
|
-
|
|
112
|
-
const payloadGetStoredCache = {
|
|
113
|
-
[identifierPK]: requestParams.identifiers[identifierPK],
|
|
114
|
-
}
|
|
115
|
-
if (identifierSK) {
|
|
116
|
-
payloadGetStoredCache[identifierSK] = requestParams.identifiers[identifierSK]
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
_izContext.logger.debug("==> payloadGetStoredCache", payloadGetStoredCache)
|
|
120
|
-
|
|
121
|
-
// const getStoredCache = await dynamodbSharedLib.getItem(
|
|
122
|
-
// _izContext,
|
|
123
|
-
// await dynamodbSharedLib.tableName(_izContext, tableName),
|
|
124
|
-
// payloadGetStoredCache
|
|
125
|
-
// )
|
|
126
|
-
|
|
127
|
-
const getStoredCache = await dynamodbSharedLib.query(
|
|
128
|
-
_izContext,
|
|
129
|
-
await dynamodbSharedLib.tableName(_izContext, tableName),
|
|
130
|
-
payloadGetStoredCache
|
|
131
|
-
)
|
|
132
|
-
_izContext.logger.debug("==> getStoredCache:::", getStoredCache)
|
|
133
|
-
return ({
|
|
134
|
-
data: getStoredCache.Items[0],
|
|
135
|
-
identifierPK: identifierPK,
|
|
136
|
-
})
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
// Initialize storedCacheData variable that will be used in multiple switch cases
|
|
140
|
-
let storedCacheData = null;
|
|
141
|
-
switch (flowSchema.statusType) {
|
|
142
|
-
case "statusField":
|
|
143
|
-
const payload = {
|
|
144
|
-
identifiers: requestParams.identifiers,
|
|
145
|
-
objectType: flowSchema.objType.objectType
|
|
146
|
-
}
|
|
147
|
-
const result = await externalRequest.lambda.invokeSync(
|
|
148
|
-
_izContext,
|
|
149
|
-
await lambdaSharedLib.lambdaFunctionName(_izContext, "GetHdrInv", flowSchema.objType.serviceTag),
|
|
150
|
-
payload
|
|
151
|
-
)
|
|
152
|
-
if (!result) {
|
|
153
|
-
throw new NoRetryError(`statusField not found ${requestParams.identifiers}`)
|
|
154
|
-
}
|
|
155
|
-
await generatedCodeLibs.postToConnection({ message: result }, connecttionId)
|
|
156
|
-
return result
|
|
157
|
-
|
|
158
|
-
break;
|
|
159
|
-
case "storedCache":
|
|
160
|
-
// if statusType=storedCache then query storedCache > post message to client -> remove connectionId if status = error || complete
|
|
161
|
-
|
|
162
|
-
storedCacheData = await getStoredCache(flowSchema.objType.objectType)
|
|
163
|
-
_izContext.logger.debug("==> storedCacheData", storedCacheData)
|
|
164
|
-
|
|
165
|
-
if (!storedCacheData) {
|
|
166
|
-
throw new NoRetryError(`storedCache not found ${requestParams.identifiers} ${requestParams.sortKey}`)
|
|
167
|
-
}
|
|
168
|
-
let payloadPostMessage = {
|
|
169
|
-
identifierTask: requestParams.identifiers[storedCacheData.identifierPK],
|
|
170
|
-
connectionId: _izContext.correlationIds.get(consts.CONNECTION_ID),
|
|
171
|
-
flowType: {
|
|
172
|
-
flowTag: flowSchema.flowTag,
|
|
173
|
-
serviceTag: process.env.iz_serviceTag,
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
_izContext.logger.debug('==> payloadPostMessage', payloadPostMessage)
|
|
178
|
-
if (storedCacheData.data.cacheStatus !== "error" && storedCacheData.data.cacheStatus != "complete") {
|
|
179
|
-
await dynamodbSharedLib.putItem(
|
|
180
|
-
_izContext,
|
|
181
|
-
await dynamodbSharedLib.tableName(_izContext, "RegisterRecords"),
|
|
182
|
-
payloadPostMessage
|
|
183
|
-
)
|
|
184
|
-
|
|
185
|
-
return payloadPostMessage;
|
|
186
|
-
} else {
|
|
187
|
-
await dynamodbSharedLib.deleteItem(
|
|
188
|
-
_izContext,
|
|
189
|
-
await dynamodbSharedLib.tableName(_izContext, "RegisterRecords"),
|
|
190
|
-
{
|
|
191
|
-
identifierTask: requestParams.identifiers[storedCacheData.identifierPK],
|
|
192
|
-
connectionId: _izContext.correlationIds.get(consts.CONNECTION_ID)
|
|
193
|
-
}
|
|
194
|
-
)
|
|
195
|
-
}
|
|
196
|
-
await generatedCodeLibs.postToConnection({ message: result }, connecttionId)
|
|
197
|
-
return storedCacheData;
|
|
198
|
-
|
|
199
|
-
case "none":
|
|
200
|
-
break;
|
|
201
|
-
default:
|
|
202
|
-
throw new NoRetryError(`statusType not found ${flowSchema.statusType}`)
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
// post result to connectionId
|
|
206
|
-
} catch (err) {
|
|
207
|
-
_izContext.logger.error('error WebSocketInvoke: ', err)
|
|
208
|
-
throw (err)
|
|
209
|
-
}
|
|
210
|
-
}
|
|
@@ -1,77 +0,0 @@
|
|
|
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 { ACTIONS, HANDLER } = require('@izara_project/izara-core-library-service-schemas/src/Consts');
|
|
23
|
-
|
|
24
|
-
const {
|
|
25
|
-
firstLetterLowerCase: lowerCase,
|
|
26
|
-
firstLetterUpperCase: upperCase,
|
|
27
|
-
} = require("../../../../../MainLibs/src/Utils");
|
|
28
|
-
const {
|
|
29
|
-
DEFAULT_HANDLER_PER_ACTION,
|
|
30
|
-
SOURCE_PATH,
|
|
31
|
-
SAVE_FILE_NAME,
|
|
32
|
-
FUNCTION_NAME,
|
|
33
|
-
SOURCE_GENERATE_IAM_ROLE
|
|
34
|
-
} = require("../../../../../MainLibs/src/Consts");
|
|
35
|
-
|
|
36
|
-
const templatePath = path.join(__dirname, "./template.ejs");
|
|
37
|
-
// /ResourceYaml/sns-out/template.ejs
|
|
38
|
-
// /OutPerActionComplete/OutUpdateComplete/sns-out/data.js
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* create data for dynamoDbYaml tempalte from objectSchema
|
|
42
|
-
* return array of dynamoDb data
|
|
43
|
-
* because one objectSchema can create multiple dynamoDb table
|
|
44
|
-
*
|
|
45
|
-
* @param {Object} _izContext
|
|
46
|
-
* @param {String} saveFilePath
|
|
47
|
-
* @returns {Object[]} - data of multiple dynamoDb template
|
|
48
|
-
*/
|
|
49
|
-
function data(_izContext, flowSchema, srcPath) {
|
|
50
|
-
const createSourceParams = createParamsForCreateSource(_izContext, flowSchema, srcPath)
|
|
51
|
-
return createSourceParams
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
function createParamsForCreateSource(_izContext, flowSchema, srcPath) {
|
|
55
|
-
//TranslateIds_Test_TranslateIdsComplete_Out
|
|
56
|
-
let flowSteps = Object.keys(flowSchema.flowSteps)
|
|
57
|
-
let flowStepTopicOut = flowSteps[1];
|
|
58
|
-
let topicComponent = flowStepTopicOut.split("_");
|
|
59
|
-
const queueName = `${upperCase(topicComponent[2])}_${upperCase(topicComponent[3])}`
|
|
60
|
-
return [
|
|
61
|
-
{
|
|
62
|
-
templatePath: templatePath,
|
|
63
|
-
templateData: {
|
|
64
|
-
queueName: upperCase(queueName),
|
|
65
|
-
},
|
|
66
|
-
setting: {
|
|
67
|
-
initialData: 'Resources:\n',
|
|
68
|
-
savePath: path.join(srcPath, SOURCE_PATH.resourceYaml),
|
|
69
|
-
saveFileName: SAVE_FILE_NAME.snsOutYaml,
|
|
70
|
-
fileExtension: '.yml',
|
|
71
|
-
isAppend: true
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
]
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
module.exports = data
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
##--------- [Create Topic Out]
|
|
2
|
-
Out<%- firstLetterUpperCase(queueName) %>:
|
|
3
|
-
Type: AWS::SNS::Topic
|
|
4
|
-
Properties:
|
|
5
|
-
DisplayName: "SNS Message out"
|
|
6
|
-
TopicName: ${self:custom.iz_serviceTag}_${self:custom.iz_stage}_<%- firstLetterUpperCase(queueName) %>
|
|
7
|
-
|
|
8
|
-
<%_ function firstLetterUpperCase(text) { return text.charAt(0).toUpperCase() + text.slice(1) } _%>
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
<%_ const join = require('path').join _%>
|
|
2
|
-
<%- firstLetterUpperCase(functionNameConfig) %>:
|
|
3
|
-
handler: <%- join(resourceLocation, `${firstLetterUpperCase(functionName)}Out_${firstLetterUpperCase(handlerType)}.main`) %>
|
|
4
|
-
name: ${self:custom.iz_resourcePrefix}<%- firstLetterUpperCase(functionNameConfig) %>
|
|
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: <%- firstLetterUpperCase(roleName) _%>Role
|
|
10
|
-
#<#<%- functionName %><%- handlerType %>IamRole#>
|
|
11
|
-
#<#/<%- functionName %><%- 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
|
-
} _%>
|
|
@@ -1,64 +0,0 @@
|
|
|
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
|
-
const { FLOW_SCHEMA_HOOK_STATE, HANDLER } = require('@izara_project/izara-core-library-service-schemas/src/Consts')
|
|
22
|
-
|
|
23
|
-
const { SOURCE_PATH, FUNCTION_NAME, SOURCE_GENERATE_IAM_ROLE } = require("../../../../../../MainLibs/src/Consts");
|
|
24
|
-
const { firstLetterLowerCase: lowerCase, firstLetterUpperCase: upperCase } = require("../../../../../../MainLibs/src/Utils");
|
|
25
|
-
const templatePath = path.join(__dirname, "template.ejs")
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* receive objectSchema
|
|
29
|
-
* create data for SQS handler template
|
|
30
|
-
*
|
|
31
|
-
* @param {Object} objectSchema
|
|
32
|
-
* @return {{templatePath, templateData,setting}}
|
|
33
|
-
*/
|
|
34
|
-
function data(_izContext, flowSchema, srcPath) {
|
|
35
|
-
return [createParamsForCreateSource(_izContext, flowSchema, srcPath)]
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
function createParamsForCreateSource(_izContext, flowSchema, srcPath) {
|
|
39
|
-
const flowStepInSplitKey = Object.keys(flowSchema.flowSteps)[0].split('_');
|
|
40
|
-
if (flowStepInSplitKey.length < 4) {
|
|
41
|
-
_izContext.logger.error(`flowStepInSplitKey.length < 4: ${flowStepInSplitKey.length} ${flowSchema.flowTag}`);
|
|
42
|
-
return null;
|
|
43
|
-
}
|
|
44
|
-
let functionName = upperCase(flowSchema.flowTag) + "ExternalTopicOut"
|
|
45
|
-
let handlerType = upperCase(HANDLER.hdrSqs);
|
|
46
|
-
return {
|
|
47
|
-
templatePath: templatePath,
|
|
48
|
-
templateData: {
|
|
49
|
-
queueName: functionName + handlerType,
|
|
50
|
-
fileName: functionName + '_Main',
|
|
51
|
-
functionMain: functionName + 'Main',
|
|
52
|
-
handler: HANDLER.hdrSqs,
|
|
53
|
-
firstLetterUpperCase: upperCase,
|
|
54
|
-
functionName
|
|
55
|
-
},
|
|
56
|
-
setting: {
|
|
57
|
-
savePath: path.join(srcPath, SOURCE_PATH.flowSchema, flowSchema.flowTag, 'source/'),
|
|
58
|
-
saveFileName: `${functionName}_${handlerType}`,
|
|
59
|
-
fileExtension: ".js",
|
|
60
|
-
isAppend: false
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
module.exports = data
|
|
@@ -1,61 +0,0 @@
|
|
|
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, HANDLER } = require("../../../../../../MainLibs/src/Consts");
|
|
23
|
-
const { firstLetterLowerCase: lowerCase, firstLetterUpperCase: upperCase } = require("../../../../../../MainLibs/src/Utils");
|
|
24
|
-
const templatePath = path.join(__dirname, "template.ejs");
|
|
25
|
-
const getObjectSchema = require('@izara_project/izara-core-library-service-schemas/src/GetObjectSchema')
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* receive objectSchema
|
|
29
|
-
* create data for Sqs Main template
|
|
30
|
-
*
|
|
31
|
-
* @param {Object} objectSchema
|
|
32
|
-
* @return {{templatePath, templateData,setting}}
|
|
33
|
-
*/
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
function data(_izContext, flowSchema, srcPath) {
|
|
37
|
-
return [createParamsForCreateSource(_izContext, flowSchema, srcPath)]
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
function createParamsForCreateSource(_izContext, flowSchema, srcPath) {
|
|
41
|
-
let functionName = upperCase(flowSchema.flowTag) + "ExternalTopicOut";
|
|
42
|
-
let snsTopicIn = Object.keys(flowSchema.flowSteps)
|
|
43
|
-
let snsTopicInWithoutUnderscore = snsTopicIn[0].replace(/_/g, '')
|
|
44
|
-
let handlerType = upperCase(HANDLER.hdrSqs);
|
|
45
|
-
// let objectSchema = await getObjectSchema.getObjectSchemaCombineFieldNamesWithCache(_izContext, flowSchema.objType)
|
|
46
|
-
// let fieldNames = Object.keys(objectSchema.fieldNames)
|
|
47
|
-
return {
|
|
48
|
-
templatePath: templatePath,
|
|
49
|
-
templateData: {
|
|
50
|
-
snsTopicIn: snsTopicInWithoutUnderscore,
|
|
51
|
-
externalTopicOutMain: functionName,
|
|
52
|
-
},
|
|
53
|
-
setting: {
|
|
54
|
-
savePath: path.join(srcPath, SOURCE_PATH.flowSchema, flowSchema.flowTag, 'source/'),
|
|
55
|
-
saveFileName: `${functionName}_Main`,
|
|
56
|
-
fileExtension: ".js",
|
|
57
|
-
isAppend: false
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
module.exports = data
|