@izara_project/izara-core-generate-service-code 1.0.53 → 1.0.55
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 -2
- package/src/codeGenerators/app/initial_setup/InitialSetupGenerator.js +1 -1
- package/src/codeGenerators/app/sls_yaml/FindDataYamlGenerator.js +23 -0
- package/src/codeGenerators/app/sls_yaml/FunctionYamlGenerator.js +16 -16
- package/src/codeGenerators/app/sls_yaml/ProcessLogicalYamlGenerator.js +11 -25
- package/src/codeGenerators/app/sls_yaml/RoleNameConfigGenerator.js +1 -1
- package/src/codeGenerators/app/sls_yaml/SharedResourceYamlGenerator.js +3 -3
- package/src/codeGenerators/app/sls_yaml/renderYamlTemplate.js +13 -0
- package/src/codeGenerators/app/sls_yaml/templates/SharedResource_Yaml.ejs +6 -2
- package/src/codeGenerators/app/src/generatedCode/FindData/FindDataGenerator.js +10 -44
- package/src/codeGenerators/app/src/generatedCode/Flow/FlowEndpoints/EndpointsGenerator.js +119 -0
- package/src/codeGenerators/app/src/generatedCode/Flow/FlowRbac/RbacFlowGenerator.js +91 -52
- package/src/codeGenerators/app/src/generatedCode/Flow/FlowRelationshipEndpoints/RelationshipFlowGenerator.js +20 -16
- package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/StatusFieldGenerator.js +2 -9
- package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/WebSocketGenerator.js +1 -7
- package/src/codeGenerators/app/src/generatedCode/Flow/{_internal → _shared}/events/BaseSqsHandler.js +3 -3
- package/src/codeGenerators/app/src/generatedCode/Flow/{_internal → _shared}/events/s3Components/ConfirmAfterUploadS3Generator.js +2 -4
- package/src/codeGenerators/app/src/generatedCode/Flow/{_internal → _shared}/events/s3Components/CreateObjectGenerator.js +2 -4
- package/src/codeGenerators/app/src/generatedCode/Flow/{_internal → _shared}/events/s3Components/CreatePreSignUrlGenerator.js +2 -4
- package/src/codeGenerators/app/src/generatedCode/Flow/{_internal → _shared}/events/s3Components/ProcessAfterUploadS3Generator.js +5 -5
- package/src/codeGenerators/app/src/generatedCode/Flow/{_internal → _shared}/events/s3Components/ReservedLimitGenerator.js +2 -4
- package/src/codeGenerators/app/src/generatedCode/Flow/{_internal → _shared}/shared/flowEntryPointBase.js +6 -6
- package/src/codeGenerators/app/src/generatedCode/Flow/{_internal → _shared}/shared/flowMainFunctionBase.js +3 -3
- package/src/codeGenerators/app/src/generatedCode/Flow/{_internal → _shared}/shared/flowStepBase.js +11 -11
- package/src/codeGenerators/app/src/generatedCode/Flow/{_internal → _shared}/shared/triggerCacheBase.js +1 -7
- package/src/codeGenerators/app/src/generatedCode/ProcessLogical/ProcessLogicalGenerator.js +18 -15
- package/src/codeGenerators/app/src/generatedCode/ProcessLogical/templates/{PaginateProcessLogical_HdrDsq.js → PaginateProcessLogical_HdrDsq.ejs} +1 -1
- package/src/codeGenerators/app/src/generatedCode/SystemFlowSchemas/RegisterGenerator.js +127 -149
- package/src/codeGenerators/app/src/generatedCode/libs/ConstsGenerator.js +16 -8
- package/src/codeGenerators/app/src/generatedCode/libs/GenerateCodeLibsGenerator.js +17 -9
- package/src/codeGenerators/resource/sls_yaml/DynamoDBGenerator.js +8 -8
- package/src/codeGenerators/resource/sls_yaml/FlowOutGenerator.js +60 -43
- package/src/codeGenerators/resource/sls_yaml/FlowResourceYamlGenerator.js +151 -151
- package/src/codeGenerators/resource/sls_yaml/templates/crud/ResourceYaml.ejs +10 -10
- package/src/core/renderTemplateFile.js +22 -0
- package/src/generateCode.js +146 -81
- package/src/generateIntTest.js +45 -69
- package/src/generateResourceIntTest.js +22 -47
- package/src/intTestGeneratorShared.js +36 -0
- package/src/schemaGenerators/app/src/schemas/FlowSchemas/templates/DynamicFlowSchemaTemplate.ejs +12 -10
- package/src/schemaGenerators/app/src/schemas/FlowSchemas/templates/RelationshipFlowSchemaTemplate.ejs +6 -5
- package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/flowSchemaMainFunction/data.js +0 -119
- package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/flowSchemaMainFunction/template.ejs +0 -89
- package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/flowSchemaMainFunction/templateByStatusType/statusFieldTemplate.ejs +0 -30
- package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/flowSchemaMainFunction/templateByStatusType/storedCacheTemplate.ejs +0 -26
- package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/flowSchemaMainFunction/templateByStatusType/triggerCacheTemplate.ejs +0 -44
- package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/index.js +0 -80
- package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/confirmReserved/functionYaml/data.js +0 -129
- package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/confirmReserved/functionYaml/template.ejs +0 -17
- package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/confirmReserved/handler/data.js +0 -63
- package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/confirmReserved/mainFunction/data.js +0 -54
- package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/confirmReserved/mainFunction/template.ejs +0 -129
- package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/confirmReserved/queue/data.js +0 -63
- package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/confirmReserved/queue/template.ejs +0 -45
- package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/createObject/functionYaml/data.js +0 -117
- package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/createObject/functionYaml/template.ejs +0 -20
- package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/createObject/handler/data.js +0 -64
- package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/createObject/mainFunction/data.js +0 -64
- package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/createObject/mainFunction/template.ejs +0 -131
- package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/createObjectComplete/functionYaml/data.js +0 -122
- package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/createObjectComplete/functionYaml/template.ejs +0 -17
- package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/createObjectComplete/handler/data.js +0 -66
- package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/createObjectComplete/handler/template.ejs +0 -99
- package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/createObjectComplete/mainFunction/data.js +0 -64
- package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/createObjectComplete/mainFunction/template.ejs +0 -82
- package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/createObjectComplete/sns-sqs/data.js +0 -70
- package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/createObjectComplete/sns-sqs/template.ejs +0 -49
- package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/preSignUrl/createPreSignUrl/functionYaml/data.js +0 -139
- package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/preSignUrl/createPreSignUrl/functionYaml/template.ejs +0 -18
- package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/preSignUrl/createPreSignUrl/handler/data.js +0 -63
- package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/preSignUrl/createPreSignUrl/mainFunction/data.js +0 -63
- package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/preSignUrl/createPreSignUrl/mainFunction/template.ejs +0 -262
- package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/preSignUrl/createPreSignUrl/queue/data.js +0 -63
- package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/preSignUrl/createPreSignUrl/queue/template.ejs +0 -45
- package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/preSignUrl/reservedLimit/functionYaml/data.js +0 -146
- package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/preSignUrl/reservedLimit/functionYaml/template.ejs +0 -14
- package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/preSignUrl/reservedLimit/handler/data.js +0 -64
- package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/preSignUrl/reservedLimit/mainFunction/data.js +0 -59
- package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/preSignUrl/reservedLimit/mainFunction/template.ejs +0 -173
- package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/preSignUrl/reservedLimit/sqs/data.js +0 -67
- package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/preSignUrl/reservedLimit/sqs/template.ejs +0 -53
- package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/processFile/functionYml/HdrS3/data.js +0 -140
- package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/processFile/functionYml/HdrS3/template.ejs +0 -25
- package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/processFile/handler/handlerS3/data.js +0 -49
- package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/processFile/handler/handlerS3/template.ejs +0 -50
- package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/processFile/mainFunction/ProcessCsvtemplate.ejs +0 -182
- package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/processFile/mainFunction/data.js +0 -49
- package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/processFile/mainFunction/template.ejs +0 -66
- package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/processFile/queue/data.js +0 -77
- package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/processFile/queue/dsqTemplatePath.ejs +0 -32
- package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/processFile/queue/s3Template.ejs +0 -59
- package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/relate/S3/data.js +0 -61
- package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/relate/S3/template.ejs +0 -13
- package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/upload/relate/sns-out/data.js +0 -70
- package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/websocket/dynamoDb/ReservedTableData.js +0 -69
- package/src/codeGenerators/app/src/generatedCode/Flow/SystemFlowDescriptorBuilder.js +0 -151
- /package/src/codeGenerators/app/{src/generatedCode/FindData → sls_yaml}/templates/FindData_Yaml.ejs +0 -0
- /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal/_shared/endpoint → FlowEndpoints/templates}/FlowEndpointBeforeLogical_Main.ejs +0 -0
- /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal/_shared → FlowSchemas/templates}/endpoint/FlowEndpoint_HdrWbs.ejs +0 -0
- /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal/_shared → FlowSchemas/templates}/endpoint/FlowEndpoint_Main.ejs +0 -0
- /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal/_shared → FlowSchemas/templates}/endpoint/FlowEntryPoint_Main.ejs +0 -0
- /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal/_shared → FlowSchemas/templates}/endpoint/FlowMain_Wbs.ejs +0 -0
- /package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/{s3Legacy/upload/confirmReserved/handler/template.ejs → s3/ConfirmReserved_HdrSqs.ejs} +0 -0
- /package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/{s3Legacy/upload/createObject/handler/template.ejs → s3/CreateObject_HdrWbs.ejs} +0 -0
- /package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/{s3Legacy/upload/preSignUrl/createPreSignUrl/handler/template.ejs → s3/CreatePreSignUrl_HdrSqs.ejs} +0 -0
- /package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/{s3Legacy/upload/preSignUrl/reservedLimit/handler/template.ejs → s3/ReservedLimit_HdrSqs.ejs} +0 -0
- /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal/_shared → FlowSchemas/templates}/step/FlowEndpointComplete_Main.ejs +0 -0
- /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal/_shared → FlowSchemas/templates}/step/FlowStep_Main.ejs +0 -0
- /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal/_shared → FlowSchemas/templates}/step/plugIns/FlowStep_ByConfig_Awaiting_Main.ejs +0 -0
- /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal/_shared → FlowSchemas/templates}/step/plugIns/FlowStep_ByConfig_Paginated_Main.ejs +0 -0
- /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal/_shared → FlowSchemas/templates}/step/plugIns/FlowStep_PlugIn_Main.ejs +0 -0
- /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal/_shared → FlowSchemas/templates}/step/plugIns/FlowStep_RecievePlugIn_Main.ejs +0 -0
- /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal/_shared → FlowSchemas/templates}/step/plugIns/templateAwaitingStep.ejs +0 -0
- /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal/_shared → FlowSchemas/templates}/step/plugIns/templateSendPlugin.ejs +0 -0
- /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal → _shared}/events/eventBridge.js +0 -0
- /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal → _shared}/events/extTopic.js +0 -0
- /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal → _shared}/events/lambdaSyncApi.js +0 -0
- /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal → _shared}/events/lambdaSyncInv.js +0 -0
- /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal → _shared}/events/ownTopic.js +0 -0
- /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal → _shared}/events/registry.js +0 -0
- /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal → _shared}/events/s3.js +0 -0
- /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal/_shared → _shared}/handlers/FlowHandler_HdrApi.ejs +0 -0
- /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal/_shared → _shared}/handlers/FlowHandler_HdrInv.ejs +0 -0
- /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal/_shared → _shared}/handlers/FlowHandler_HdrSqs.ejs +0 -0
- /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal → _shared}/shared/eventTypes.js +0 -0
- /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal → _shared}/shared/flowClassifier.js +0 -0
- /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal → _shared}/shared/flowNaming.js +0 -0
- /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal → _shared}/shared/flowSelection.js +0 -0
- /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal → _shared}/shared/flowStepNormalizer.js +0 -0
- /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal → _shared}/shared/flowValidator.js +0 -0
- /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal → _shared}/shared/registry.js +0 -0
- /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal/_shared → _shared}/triggerCache/CheckTriggerCache_HdrSqs.ejs +0 -0
- /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal/_shared → _shared}/triggerCache/CheckTriggerCache_Main.ejs +0 -0
- /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal/_shared → _shared}/triggerCache/ProcessTriggerCache_HdrSqs.ejs +0 -0
- /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal/_shared → _shared}/triggerCache/ProcessTriggerCache_Main.ejs +0 -0
- /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal/_shared → _shared}/triggerCache/TriggerCacheComplete_HdrDsq.ejs +0 -0
- /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal/_shared → _shared}/triggerCache/TriggerCacheComplete_HdrSqs.ejs +0 -0
- /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal/_shared → _shared}/triggerCache/TriggerCacheComplete_Main.ejs +0 -0
- /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal/_shared → _shared}/triggerCache/TriggerCacheQueue_Yaml.ejs +0 -0
- /package/src/codeGenerators/app/src/generatedCode/Flow/{_internal/_shared → _shared}/yaml/SharedFunctionSqs_Yaml.ejs +0 -0
- /package/src/codeGenerators/app/src/generatedCode/ProcessLogical/templates/{PaginateProcessLogical_HdrSqs.js → PaginateProcessLogical_HdrSqs.ejs} +0 -0
- /package/src/codeGenerators/app/src/generatedCode/ProcessLogical/templates/{PaginateProcessLogical_Main.js → PaginateProcessLogical_Main.ejs} +0 -0
- /package/src/codeGenerators/app/src/generatedCode/ProcessLogical/templates/{ProcessLogical_HdrSqs.js → ProcessLogical_HdrSqs.ejs} +0 -0
- /package/src/codeGenerators/app/src/generatedCode/ProcessLogical/templates/{ProcessLogical_Main.js → ProcessLogical_Main.ejs} +0 -0
- /package/src/codeGenerators/app/src/generatedCode/libs/templates/{Consts.js → Consts.ejs} +0 -0
- /package/src/codeGenerators/app/src/generatedCode/libs/templates/{GenerateCodeLibs.js → GenerateCodeLibs.ejs} +0 -0
|
@@ -1,131 +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
|
-
|
|
20
|
-
|
|
21
|
-
import { getObjectSchema } from '@izara_project/izara-core-library-service-schemas';
|
|
22
|
-
import { consts } from '@izara_project/izara-middleware';
|
|
23
|
-
|
|
24
|
-
import dynamodbSharedLib from '@izara_project/izara-core-library-dynamodb';
|
|
25
|
-
import snsSharedLib from '@izara_project/izara-core-library-sns';
|
|
26
|
-
import callingFlowSharedLib from '@izara_project/izara-core-library-calling-flow';
|
|
27
|
-
import lambdaSharedLib from '@izara_project/izara-core-library-lambda';
|
|
28
|
-
|
|
29
|
-
import { sns } from '@izara_project/izara-core-library-external-request';
|
|
30
|
-
|
|
31
|
-
import { NoRetryError } from '@izara_project/izara-core-library-core';
|
|
32
|
-
import { consts as generateCodeConsts } from '@izara_project/izara-core-generate-service-code';
|
|
33
|
-
const { TOPIC_NAME_GENERATE_CODE } = generateCodeConsts;
|
|
34
|
-
|
|
35
|
-
//(<optionalRequired>)
|
|
36
|
-
//(</optionalRequired>)
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
* description of function.
|
|
42
|
-
* @param {Object} _izContext
|
|
43
|
-
* @param {CorrelationIds} _izContext.correlationIds - property of _izContext
|
|
44
|
-
* @param {Logger} _izContext.logger - property of _izContext
|
|
45
|
-
* @param {Object} requestParams - request params
|
|
46
|
-
* @param {Object} requestParams.identifiers - identifiers for get data
|
|
47
|
-
* @param {Object} requestParams.additionalRequest - additionalRequest
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
* @returns {object} description of return value
|
|
51
|
-
*/
|
|
52
|
-
|
|
53
|
-
export default async function <%= functionName %>(
|
|
54
|
-
_izContext,
|
|
55
|
-
requestParams,
|
|
56
|
-
callingFlowConfig = {},
|
|
57
|
-
//(<additionalParams>)
|
|
58
|
-
//(</additionalParams>)
|
|
59
|
-
) {
|
|
60
|
-
|
|
61
|
-
try {
|
|
62
|
-
_izContext.logger.debug("WebSocketInvoke _izContext", _izContext)
|
|
63
|
-
_izContext.logger.debug("WebSocketInvoke requestParams", requestParams)
|
|
64
|
-
_izContext.logger.debug("WebSocketInvoke callingFlowConfig", callingFlowConfig)
|
|
65
|
-
|
|
66
|
-
let connectionId = _izContext.correlationIds.get(consts.CONNECTION_ID)
|
|
67
|
-
|
|
68
|
-
let flowSchema = await getObjectSchema.getFlowSchemaS3WithCache(_izContext, {
|
|
69
|
-
flowTag: "<%- flowTag %>",
|
|
70
|
-
serviceTag: process.env.iz_serviceTag
|
|
71
|
-
})
|
|
72
|
-
|
|
73
|
-
_izContext.logger.debug("getFlowSchema", flowSchema)
|
|
74
|
-
|
|
75
|
-
let getUserFromTableUserUploadRecord = await dynamodbSharedLib.getItem(_izContext,
|
|
76
|
-
await dynamodbSharedLib.tableName(_izContext, "UserUploadRecords"),
|
|
77
|
-
{
|
|
78
|
-
connectionId: connectionId
|
|
79
|
-
}
|
|
80
|
-
)
|
|
81
|
-
|
|
82
|
-
const { userId, submittedByUserId } = getUserFromTableUserUploadRecord
|
|
83
|
-
_izContext.correlationIds.set(consts.BASE_USER_ID, userId)
|
|
84
|
-
_izContext.correlationIds.set(consts.TARGET_ID, submittedByUserId)
|
|
85
|
-
|
|
86
|
-
if (!flowSchema) {
|
|
87
|
-
throw new NoRetryError(`flowTag not found ${requestParams.action}`)
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
// get objectType
|
|
91
|
-
let objectSchema = await getObjectSchema.getObjSchemaS3WithHierarchy(_izContext, flowSchema.objType)
|
|
92
|
-
_izContext.logger.debug("objectSchema in flowSchema mainFunction", objectSchema)
|
|
93
|
-
|
|
94
|
-
if (!objectSchema) {
|
|
95
|
-
throw new NoRetryError(`${flowSchema.objType.objectType} not found`)
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
//(<beforeCreateHook>)
|
|
99
|
-
//(</beforeCreateHook>)
|
|
100
|
-
// create message Object to create Endpoint
|
|
101
|
-
let messageObject = {
|
|
102
|
-
objectType: "<%- objectType %>",
|
|
103
|
-
fieldNames: {
|
|
104
|
-
//(<fieldNamesHook>)
|
|
105
|
-
//(</fieldNamesHook>)
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
// create callingFlow
|
|
109
|
-
messageObject = callingFlowSharedLib.addCallingFlowToSnsRequestMessageObject(
|
|
110
|
-
messageObject,
|
|
111
|
-
callingFlowSharedLib.addParentCallingFlowConfig(
|
|
112
|
-
callingFlowConfig,
|
|
113
|
-
callingFlowSharedLib.createCallingFlowConfig(
|
|
114
|
-
await lambdaSharedLib.lambdaFunctionName(_izContext, TOPIC_NAME_GENERATE_CODE.createNodeComplete), {}
|
|
115
|
-
)
|
|
116
|
-
)
|
|
117
|
-
)
|
|
118
|
-
|
|
119
|
-
// send message to Create endpoint
|
|
120
|
-
let sendMessageToCreateEndpoint = {
|
|
121
|
-
Message: JSON.stringify(messageObject),
|
|
122
|
-
TopicArn: await snsSharedLib.snsTopicArnByFlowSchema(_izContext, "Create_In")
|
|
123
|
-
}
|
|
124
|
-
_izContext.logger.debug("sendMessageToCreateEndpoint", sendMessageToCreateEndpoint);
|
|
125
|
-
await sns.publishAsync(_izContext, sendMessageToCreateEndpoint);
|
|
126
|
-
|
|
127
|
-
} catch (err) {
|
|
128
|
-
_izContext.logger.error('error WebSocketInvoke: ', err)
|
|
129
|
-
throw (err)
|
|
130
|
-
}
|
|
131
|
-
}
|
|
@@ -1,122 +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
|
-
import path from 'path';
|
|
19
|
-
import { fileURLToPath } from 'url';
|
|
20
|
-
const __filename = fileURLToPath(import.meta.url);
|
|
21
|
-
const __dirname = path.dirname(__filename);
|
|
22
|
-
|
|
23
|
-
import consts from '#libs/Consts.js';
|
|
24
|
-
import utils from '#libs/Utils.js';
|
|
25
|
-
import libs from '#libs/Libs.js';
|
|
26
|
-
|
|
27
|
-
const { firstLetterLowerCase: lowerCase, firstLetterUpperCase: upperCase } =
|
|
28
|
-
utils;
|
|
29
|
-
const {
|
|
30
|
-
RESOURCE_CLASSES,
|
|
31
|
-
SQS_RESOURCE,
|
|
32
|
-
SOURCE_PATH,
|
|
33
|
-
SAVE_FILE_NAME,
|
|
34
|
-
FUNCTION_NAME,
|
|
35
|
-
DYNAMO_RESOURCE,
|
|
36
|
-
SHORT_FUNCTION_NAME,
|
|
37
|
-
SOURCE_GENERATE_IAM_ROLE
|
|
38
|
-
} = consts;
|
|
39
|
-
|
|
40
|
-
const {
|
|
41
|
-
createIamRole,
|
|
42
|
-
resourceNames,
|
|
43
|
-
shortNameHandler,
|
|
44
|
-
defaultIamRolePerAction
|
|
45
|
-
} = libs;
|
|
46
|
-
const templatePath = path.join(__dirname, 'template.ejs');
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* receive objectSchema
|
|
50
|
-
* create data for FindData Yaml template
|
|
51
|
-
*
|
|
52
|
-
* @param {Object} objectSchemas
|
|
53
|
-
* @return {{ templatePath, templateData, setting } }
|
|
54
|
-
*/
|
|
55
|
-
function data(_izContext, flowSchema, srcPath) {
|
|
56
|
-
return [createSourceParams(_izContext, flowSchema, srcPath)];
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
function createSourceParams(_izContext, flowSchema, srcPath) {
|
|
60
|
-
let functionName = upperCase(FUNCTION_NAME.createObjectS3Complete);
|
|
61
|
-
let handlerType = upperCase(HANDLER.hdrSqs);
|
|
62
|
-
let additionalResourcePermission = defaultIamRolePerAction();
|
|
63
|
-
|
|
64
|
-
additionalResourcePermission.push(
|
|
65
|
-
createIamRole(
|
|
66
|
-
{
|
|
67
|
-
[RESOURCE_CLASSES.sqs]: [
|
|
68
|
-
SQS_RESOURCE.sendMessage,
|
|
69
|
-
SQS_RESOURCE.deleteMessage,
|
|
70
|
-
SQS_RESOURCE.getQueueAttributes,
|
|
71
|
-
SQS_RESOURCE.receiveMessage
|
|
72
|
-
]
|
|
73
|
-
},
|
|
74
|
-
[
|
|
75
|
-
resourceNames(RESOURCE_CLASSES.sqs, functionName + handlerType),
|
|
76
|
-
resourceNames(RESOURCE_CLASSES.sqs, functionName + handlerType + 'DLQ')
|
|
77
|
-
]
|
|
78
|
-
),
|
|
79
|
-
createIamRole(
|
|
80
|
-
{
|
|
81
|
-
[RESOURCE_CLASSES.dynamoDbTable]: [
|
|
82
|
-
DYNAMO_RESOURCE.query,
|
|
83
|
-
DYNAMO_RESOURCE.deleteItem,
|
|
84
|
-
DYNAMO_RESOURCE.getItem
|
|
85
|
-
]
|
|
86
|
-
},
|
|
87
|
-
[resourceNames(RESOURCE_CLASSES.dynamoDbTable, 'WebSocketTask')]
|
|
88
|
-
),
|
|
89
|
-
createIamRole(
|
|
90
|
-
{
|
|
91
|
-
'execute-api': ['ManageConnections']
|
|
92
|
-
},
|
|
93
|
-
[resourceNames(RESOURCE_CLASSES.webSocket)]
|
|
94
|
-
)
|
|
95
|
-
);
|
|
96
|
-
|
|
97
|
-
return {
|
|
98
|
-
templatePath: templatePath,
|
|
99
|
-
templateData: {
|
|
100
|
-
resourceLocation: path.join(
|
|
101
|
-
SOURCE_PATH.resourceLocationWebSocket,
|
|
102
|
-
flowSchema.flowTag,
|
|
103
|
-
'source/'
|
|
104
|
-
),
|
|
105
|
-
functionName: functionName,
|
|
106
|
-
handlerType: handlerType,
|
|
107
|
-
additionalResourcePermission: additionalResourcePermission,
|
|
108
|
-
functionNameConfig:
|
|
109
|
-
upperCase(SHORT_FUNCTION_NAME(FUNCTION_NAME.createObjectS3Complete)) +
|
|
110
|
-
upperCase(shortNameHandler(handlerType)),
|
|
111
|
-
roleName: SOURCE_GENERATE_IAM_ROLE.FlowSchemaUploadS3Role
|
|
112
|
-
},
|
|
113
|
-
setting: {
|
|
114
|
-
savePath: path.join(srcPath, SOURCE_PATH.appYaml),
|
|
115
|
-
saveFileName: SAVE_FILE_NAME.flowSchemaYaml,
|
|
116
|
-
fileExtension: '.yml',
|
|
117
|
-
isAppend: true
|
|
118
|
-
}
|
|
119
|
-
};
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
export default data;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
<%_ const join = require('path').join; _%>
|
|
2
|
-
<%- firstLetterUpperCase(functionNameConfig) %>:
|
|
3
|
-
handler: <%- join(resourceLocation, `${functionName}_${firstLetterUpperCase(handlerType)}.main`)%>
|
|
4
|
-
name: ${self:custom.iz_resourcePrefix}<%- functionName %><%- firstLetterUpperCase(handlerType) %>
|
|
5
|
-
role: <%- roleName %>Role
|
|
6
|
-
#<#<%- functionName %><%- handlerType %>FunctionSetting#>
|
|
7
|
-
#<#/<%- functionName %><%- handlerType %>FunctionSetting#>
|
|
8
|
-
events:
|
|
9
|
-
- sqs:
|
|
10
|
-
arn: arn:aws:sqs:${self:custom.iz_region}:${self:custom.iz_accountId}:${self:custom.iz_resourcePrefix}<%- functionName %><%- firstLetterUpperCase(handlerType) %>
|
|
11
|
-
batchSize: 10
|
|
12
|
-
filterPatterns: #**** need to update serverless framework upper v.2.69.1
|
|
13
|
-
- body: {"MessageAttributes":{"callingFlow":{"Value":["${self:custom.iz_resourcePrefix}<%- functionName %>"]}}} # functionName of callingFlow
|
|
14
|
-
- body: {"MessageAttributes":{"callingFlow":{"Value":[{"exists":false}]}}}
|
|
15
|
-
<%_ function firstLetterUpperCase(text){
|
|
16
|
-
return text.charAt(0).toUpperCase() + text.slice(1)
|
|
17
|
-
} _%>
|
|
@@ -1,66 +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
|
-
import path from 'path';
|
|
19
|
-
import { fileURLToPath } from 'url';
|
|
20
|
-
const __filename = fileURLToPath(import.meta.url);
|
|
21
|
-
const __dirname = path.dirname(__filename);
|
|
22
|
-
|
|
23
|
-
import consts from '#libs/Consts.js';
|
|
24
|
-
import utils from '#libs/Utils.js';
|
|
25
|
-
|
|
26
|
-
const { firstLetterLowerCase: lowerCase, firstLetterUpperCase: upperCase } =
|
|
27
|
-
utils;
|
|
28
|
-
const { HANDLER, SOURCE_PATH, FUNCTION_NAME } = consts;
|
|
29
|
-
|
|
30
|
-
const templatePath = path.join(__dirname, 'template.ejs');
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* receive objectSchema
|
|
34
|
-
* create data for FindData Yaml template
|
|
35
|
-
*
|
|
36
|
-
* @param {Object} objectSchemas
|
|
37
|
-
* @return {{ templatePath, templateData, setting } }
|
|
38
|
-
*/
|
|
39
|
-
function data(_izContext, flowSchema, srcPath) {
|
|
40
|
-
return [createSourceParams(_izContext, flowSchema, srcPath)];
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
function createSourceParams(_izContext, flowSchema, srcPath) {
|
|
44
|
-
let functionName = upperCase(FUNCTION_NAME.createObjectS3Complete);
|
|
45
|
-
let handlerType = upperCase(HANDLER.hdrSqs);
|
|
46
|
-
return {
|
|
47
|
-
templatePath: templatePath,
|
|
48
|
-
templateData: {
|
|
49
|
-
functionName,
|
|
50
|
-
handlerType
|
|
51
|
-
},
|
|
52
|
-
setting: {
|
|
53
|
-
savePath: path.join(
|
|
54
|
-
srcPath,
|
|
55
|
-
SOURCE_PATH.webSocket,
|
|
56
|
-
flowSchema.flowTag,
|
|
57
|
-
'source/'
|
|
58
|
-
),
|
|
59
|
-
saveFileName: `${functionName}_${handlerType}`,
|
|
60
|
-
fileExtension: '.js',
|
|
61
|
-
isAppend: false
|
|
62
|
-
}
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
export default data;
|
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Copyright (C) 2021 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
|
-
|
|
19
|
-
|
|
20
|
-
import { middlewareHandler as middleware } from '@izara_project/izara-middleware';
|
|
21
|
-
import Logger from '@izara_project/izara-core-library-logger';
|
|
22
|
-
import recordHandlerSharedLib from '@izara_project/izara-core-library-record-handler';
|
|
23
|
-
|
|
24
|
-
import webSocketTaskComplete from './WebSocketTaskComplete_Main.js'
|
|
25
|
-
|
|
26
|
-
middleware.setValidatorSchema(recordHandlerSharedLib.baseValidatorSchema());
|
|
27
|
-
// set schema for record.body.Message
|
|
28
|
-
const perRecordsValidatorSchema = {};
|
|
29
|
-
|
|
30
|
-
// // set schema for record.body.MessageAttributes
|
|
31
|
-
// const messageAttributeValidatorSchema = {
|
|
32
|
-
// type: "object",
|
|
33
|
-
// required: ['msgAtrrParam1', 'msgAtrrParam2'],
|
|
34
|
-
// properties: {
|
|
35
|
-
// msgAtrrParam1: {
|
|
36
|
-
// type: "string"
|
|
37
|
-
// },
|
|
38
|
-
// msgAtrrParam2: {
|
|
39
|
-
// type: "object"
|
|
40
|
-
// }
|
|
41
|
-
// }
|
|
42
|
-
// };
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
// middleware.setValidatorSchema(recordHandlerSharedLib.baseValidatorSchema(perRecordsValidatorSchema));
|
|
46
|
-
|
|
47
|
-
export const main = middleware.wrap(async (event, context) => {
|
|
48
|
-
|
|
49
|
-
try {
|
|
50
|
-
Logger.debug('event ReceiveMsgOutHdrSqs: ', event)
|
|
51
|
-
let recordPromises = [];
|
|
52
|
-
|
|
53
|
-
// loop each record and send to mainFunction
|
|
54
|
-
await Promise.all(event.Records.map(async record => { // promise.all for map() function
|
|
55
|
-
|
|
56
|
-
let passOnProperties = []
|
|
57
|
-
record._izContext.logger.debug('record ReceiveMsgOutHdrSqs', record);
|
|
58
|
-
|
|
59
|
-
//validate message (and MessageAttributes)
|
|
60
|
-
await recordHandlerSharedLib.validateRecord(
|
|
61
|
-
record, // one record will send to mainFunction
|
|
62
|
-
"WebSocketTaskCompleteHdrSqs", // queue name that need to retry or send to dlq
|
|
63
|
-
perRecordsValidatorSchema, // schema for record.Message
|
|
64
|
-
// messageAttributeValidatorSchema // ----- for msgAttr default is null -> do not send this parameter if not want to validate msgAtt
|
|
65
|
-
);
|
|
66
|
-
|
|
67
|
-
// add argument (to invoke lambda) to passOnProperties[]
|
|
68
|
-
// passOnProperties.push(record.body.Message.MessageAttributes)
|
|
69
|
-
passOnProperties.push(record.body.Message.objType)
|
|
70
|
-
passOnProperties.push(record.body.Message.updateItem)
|
|
71
|
-
// passOnProperties.push(record.body.Message.route)
|
|
72
|
-
Logger.debug('passOnProperties in handler', passOnProperties);
|
|
73
|
-
|
|
74
|
-
// call recordHandlerSharedLib.recordHandler with 3 parameters and return promise(resolve)
|
|
75
|
-
let recordPromise = recordHandlerSharedLib.recordHandler(
|
|
76
|
-
record, // one record will send to mainFunction
|
|
77
|
-
webSocketTaskComplete, // mainFunction that need to invoke.
|
|
78
|
-
"WebSocketTaskCompleteHdrSqs", // queue name that need to retry or send to dlq
|
|
79
|
-
passOnProperties, // all parameters that mainFunction needed.
|
|
80
|
-
);
|
|
81
|
-
record._izContext.logger.debug('after recordPromise in handler');
|
|
82
|
-
recordPromises.push(recordPromise); // push promise to recordPromises
|
|
83
|
-
}))
|
|
84
|
-
// ProcessLogical
|
|
85
|
-
Logger.debug('before Promise.all(recordPromises) in handler');
|
|
86
|
-
try {
|
|
87
|
-
await Promise.all(recordPromises); // await all promises
|
|
88
|
-
return event.Records // return all for local test
|
|
89
|
-
|
|
90
|
-
} catch {
|
|
91
|
-
Logger.debug('Promise.all(recordPromises) in handler threw error (at least one record did not resolve)');
|
|
92
|
-
}
|
|
93
|
-
Logger.debug('after Promise.all(recordPromises) in handler');
|
|
94
|
-
|
|
95
|
-
} catch (err) {
|
|
96
|
-
Logger.error('Unhandled Error, WebSocketTaskCompleteHdrSqs: ', err);
|
|
97
|
-
throw (err);
|
|
98
|
-
}
|
|
99
|
-
});
|
|
@@ -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
|
-
import path from 'path';
|
|
19
|
-
import { fileURLToPath } from 'url';
|
|
20
|
-
const __filename = fileURLToPath(import.meta.url);
|
|
21
|
-
const __dirname = path.dirname(__filename);
|
|
22
|
-
|
|
23
|
-
import consts from '#libs/Consts.js';
|
|
24
|
-
import utils from '#libs/Utils.js';
|
|
25
|
-
|
|
26
|
-
const { firstLetterLowerCase: lowerCase, firstLetterUpperCase: upperCase } =
|
|
27
|
-
utils;
|
|
28
|
-
const { SOURCE_PATH, FUNCTION_NAME } = consts;
|
|
29
|
-
|
|
30
|
-
const templatePath = path.join(__dirname, 'template.ejs');
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* receive objectSchema
|
|
34
|
-
* create data for FindData Yaml template
|
|
35
|
-
*
|
|
36
|
-
* @param {Object} objectSchemas
|
|
37
|
-
* @return {{ templatePath, templateData, setting } }
|
|
38
|
-
*/
|
|
39
|
-
function data(_izContext, flowSchema, srcPath) {
|
|
40
|
-
return [createSourceParams(_izContext, flowSchema, srcPath)];
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
function createSourceParams(_izContext, flowSchema, srcPath) {
|
|
44
|
-
let functionName = upperCase(FUNCTION_NAME.createObjectS3Complete);
|
|
45
|
-
return {
|
|
46
|
-
templatePath: templatePath,
|
|
47
|
-
templateData: {
|
|
48
|
-
functionName
|
|
49
|
-
},
|
|
50
|
-
setting: {
|
|
51
|
-
savePath: path.join(
|
|
52
|
-
srcPath,
|
|
53
|
-
SOURCE_PATH.webSocket,
|
|
54
|
-
flowSchema.flowTag,
|
|
55
|
-
'source/'
|
|
56
|
-
),
|
|
57
|
-
saveFileName: `${functionName}_Main`,
|
|
58
|
-
fileExtension: '.js',
|
|
59
|
-
isAppend: false
|
|
60
|
-
}
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
export default data;
|
|
@@ -1,82 +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
|
-
import dynamodbSharedLib from '@izara_project/izara-core-library-dynamodb';
|
|
19
|
-
import { consts as coreConsts } from '@izara_project/izara-middleware';
|
|
20
|
-
import { webSocket } from '@izara_project/izara-core-library-external-request';
|
|
21
|
-
const { postToConnection } = webSocket;
|
|
22
|
-
|
|
23
|
-
export async function webSocketTaskComplete(
|
|
24
|
-
_izContext,
|
|
25
|
-
updateItem
|
|
26
|
-
) {
|
|
27
|
-
try {
|
|
28
|
-
_izContext.logger.debug("requestParams", {
|
|
29
|
-
objType,
|
|
30
|
-
updateItem
|
|
31
|
-
})
|
|
32
|
-
|
|
33
|
-
let connectionId = _izContext.correlationIds.get(coreConsts.CONNECTION_ID);
|
|
34
|
-
let correlationId = _izContext.correlationIds.get(coreConsts.X_CORRELATION_ID);
|
|
35
|
-
|
|
36
|
-
if (updateItem.importBatchStatus === "waitingToUpload") {
|
|
37
|
-
// get upload url
|
|
38
|
-
let webSocketTask = await dynamodbSharedLib.getItem(_izContext,
|
|
39
|
-
await dynamodbSharedLib.tableName(_izContext, "WebSocketTask"),
|
|
40
|
-
{
|
|
41
|
-
taskKey: correlationId,
|
|
42
|
-
connectionId: connectionId
|
|
43
|
-
}
|
|
44
|
-
)
|
|
45
|
-
_izContext.logger.debug("webSocketTask", webSocketTask);
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
_izContext.logger.debug("post message to client")
|
|
49
|
-
// post message to client
|
|
50
|
-
await postToConnection({
|
|
51
|
-
message: {
|
|
52
|
-
uploadUrl: webSocketTask.uploadUrl,
|
|
53
|
-
importBatchId: updateItem.importBatchId
|
|
54
|
-
}
|
|
55
|
-
}, connectionId)
|
|
56
|
-
|
|
57
|
-
await dynamodbSharedLib.deleteItem(_izContext,
|
|
58
|
-
await dynamodbSharedLib.tableName(_izContext, "WebSocketTask"),
|
|
59
|
-
{
|
|
60
|
-
taskKey: correlationId,
|
|
61
|
-
connectionId: connectionId
|
|
62
|
-
}
|
|
63
|
-
)
|
|
64
|
-
} else {
|
|
65
|
-
await postToConnection({
|
|
66
|
-
message: "status is processing can't upload file"
|
|
67
|
-
}, connectionId)
|
|
68
|
-
// delete webSocketTask
|
|
69
|
-
await dynamodbSharedLib.deleteItem(_izContext,
|
|
70
|
-
await dynamodbSharedLib.tableName(_izContext, "WebSocketTask"),
|
|
71
|
-
{
|
|
72
|
-
taskKey: correlationId,
|
|
73
|
-
connectionId: connectionId
|
|
74
|
-
}
|
|
75
|
-
)
|
|
76
|
-
|
|
77
|
-
}
|
|
78
|
-
} catch (err) {
|
|
79
|
-
_izContext.logger.error('error websocketTaskComplete: ', err)
|
|
80
|
-
throw (err);
|
|
81
|
-
}
|
|
82
|
-
};
|
|
@@ -1,70 +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
|
-
import path from 'path';
|
|
19
|
-
import { fileURLToPath } from 'url';
|
|
20
|
-
const __filename = fileURLToPath(import.meta.url);
|
|
21
|
-
const __dirname = path.dirname(__filename);
|
|
22
|
-
|
|
23
|
-
import consts from '#libs/Consts.js';
|
|
24
|
-
import utils from '#libs/Utils.js';
|
|
25
|
-
|
|
26
|
-
const { firstLetterLowerCase: lowerCase, firstLetterUpperCase: upperCase } =
|
|
27
|
-
utils;
|
|
28
|
-
const { HANDLER, SOURCE_PATH, SAVE_FILE_NAME, FUNCTION_NAME } = consts;
|
|
29
|
-
|
|
30
|
-
const templatePath = path.join(__dirname, 'template.ejs');
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* create data for dynamoDbYaml tempalte from objectSchema
|
|
34
|
-
* return array of dynamoDb data
|
|
35
|
-
* because one objectSchema can create multiple dynamoDb table
|
|
36
|
-
*
|
|
37
|
-
* @param {Object} _izContext
|
|
38
|
-
* @param {String} saveFilePath
|
|
39
|
-
* @returns {Object[]} - data of multiple dynamoDb template
|
|
40
|
-
*/
|
|
41
|
-
|
|
42
|
-
function createDataForDefaultSnsInSqs(_izContext, srcPath) {
|
|
43
|
-
let resultsForCreateDefaultSnsInSqs = [];
|
|
44
|
-
const defaultSnsInSqsDataList = [];
|
|
45
|
-
const setting = {
|
|
46
|
-
initialData: 'Resources:\n',
|
|
47
|
-
savePath: path.join(srcPath, SOURCE_PATH.resourceYaml),
|
|
48
|
-
saveFileName: SAVE_FILE_NAME.snsInSqsYaml,
|
|
49
|
-
fileExtension: '.yml',
|
|
50
|
-
isAppend: true
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
defaultSnsInSqsDataList.push({
|
|
54
|
-
queueName:
|
|
55
|
-
upperCase(FUNCTION_NAME.createObjectS3Complete) +
|
|
56
|
-
upperCase(HANDLER.hdrSqs),
|
|
57
|
-
subScription: 'Out' + upperCase(FUNCTION_NAME.updateNodeComplete)
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
for (let defaultSnsInSqsData of defaultSnsInSqsDataList) {
|
|
61
|
-
resultsForCreateDefaultSnsInSqs.push({
|
|
62
|
-
templatePath: templatePath,
|
|
63
|
-
templateData: defaultSnsInSqsData,
|
|
64
|
-
setting: setting
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
return resultsForCreateDefaultSnsInSqs;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
export default createDataForDefaultSnsInSqs;
|