@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
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { existsSync, readFileSync, rmSync } from 'fs';
|
|
2
|
+
import { join } from 'path';
|
|
3
|
+
import yaml from 'yaml';
|
|
4
|
+
|
|
5
|
+
function getServiceTag(rootPath) {
|
|
6
|
+
const configPath = join(rootPath, 'config', 'serverless.config.yml');
|
|
7
|
+
const config = yaml.parse(readFileSync(configPath, 'utf8'));
|
|
8
|
+
return config?.main_config?.iz_serviceTag;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
async function runTemplateItems(items, { writeSource, errorPrefix }) {
|
|
12
|
+
const clearedPaths = new Set();
|
|
13
|
+
|
|
14
|
+
for (const item of items) {
|
|
15
|
+
if (!item || !item.templatePath || !item.templateData || !item.setting) {
|
|
16
|
+
throw new Error(`Invalid ${errorPrefix} item: missing templatePath/templateData/setting`);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const [status, error] = await writeSource(item, { checkCreateSourcePass: true });
|
|
20
|
+
if (!status) {
|
|
21
|
+
throw new Error(`${errorPrefix} template validation failed: ${error?.message || error}`);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
for (const item of items) {
|
|
26
|
+
const savePath = item.setting?.savePath;
|
|
27
|
+
if (savePath && existsSync(savePath) && !clearedPaths.has(savePath)) {
|
|
28
|
+
rmSync(savePath, { recursive: true, force: true });
|
|
29
|
+
clearedPaths.add(savePath);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
await writeSource(item, { checkCreateSourcePass: false });
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export { getServiceTag, runTemplateItems };
|
package/src/schemaGenerators/app/src/schemas/FlowSchemas/templates/DynamicFlowSchemaTemplate.ejs
CHANGED
|
@@ -22,18 +22,20 @@ export default {
|
|
|
22
22
|
messageAttributes: ['userId', 'correlationId']
|
|
23
23
|
},
|
|
24
24
|
<% if (hasBeforeLogicalStep) { %>
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
25
|
+
{
|
|
26
|
+
stepName: 'beforeLogical',
|
|
27
|
+
event: ['sqs'],
|
|
28
|
+
properties: [],
|
|
29
|
+
messageAttributes: ['userId', 'correlationId']
|
|
30
|
+
},
|
|
30
31
|
<% } %>
|
|
31
32
|
<% if (['Create', 'Update', 'Delete'].includes(action)) { %>
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
33
|
+
{
|
|
34
|
+
stepName: 'Complete',
|
|
35
|
+
event: ['sqs'],
|
|
36
|
+
properties: [],
|
|
37
|
+
messageAttributes: ['userId', 'correlationId']
|
|
38
|
+
}
|
|
37
39
|
<% } %>
|
|
38
40
|
]
|
|
39
41
|
};
|
|
@@ -22,11 +22,12 @@ export default {
|
|
|
22
22
|
messageAttributes: ['userId', 'correlationId']
|
|
23
23
|
}
|
|
24
24
|
<% if (hasCompleteStep) { %>,
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
25
|
+
{
|
|
26
|
+
stepName: 'Complete',
|
|
27
|
+
event: ['sqs'],
|
|
28
|
+
properties: [],
|
|
29
|
+
messageAttributes: ['userId', 'correlationId']
|
|
30
|
+
}
|
|
30
31
|
<% } %>
|
|
31
32
|
]
|
|
32
33
|
};
|
|
@@ -1,119 +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 { NoRetryError } from '@izara_project/izara-core-library-core';
|
|
24
|
-
import {
|
|
25
|
-
getObjectSchema,
|
|
26
|
-
utils as coreUtils
|
|
27
|
-
} from '@izara_project/izara-core-library-service-schemas';
|
|
28
|
-
const { createFlowTypeConcat } = coreUtils;
|
|
29
|
-
|
|
30
|
-
import consts from '#libs/Consts.js';
|
|
31
|
-
import utils from '#libs/Utils.js';
|
|
32
|
-
const { SOURCE_PATH, STORAGE_TYPES } = consts;
|
|
33
|
-
const { firstLetterUpperCase: upperCase, getLocalConfig, savePath } = utils;
|
|
34
|
-
|
|
35
|
-
const templatePath = path.join(__dirname, 'template.ejs');
|
|
36
|
-
const statusFieldTemplate = path.join(
|
|
37
|
-
__dirname,
|
|
38
|
-
'./templateByStatusType/statusFieldTemplate.ejs'
|
|
39
|
-
);
|
|
40
|
-
const storedCacheTemplate = path.join(
|
|
41
|
-
__dirname,
|
|
42
|
-
'./templateByStatusType/storedCacheTemplate.ejs'
|
|
43
|
-
);
|
|
44
|
-
const triggerCacheTemplate = path.join(
|
|
45
|
-
__dirname,
|
|
46
|
-
'./templateByStatusType/triggerCacheTemplate.ejs'
|
|
47
|
-
);
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* receive objectSchema
|
|
51
|
-
* create data for WebScoket handler template
|
|
52
|
-
*
|
|
53
|
-
* @param {Object} objectSchema
|
|
54
|
-
* @return {{templatePath, templateData,setting}}
|
|
55
|
-
*/
|
|
56
|
-
async function createParamsForCreateSource(_izContext, flowSchema, appPath) {
|
|
57
|
-
let functionName = 'Process' + upperCase(flowSchema.flowTag);
|
|
58
|
-
let tableName = null;
|
|
59
|
-
if (
|
|
60
|
-
flowSchema.statusType === 'storedCache' ||
|
|
61
|
-
flowSchema.statusType === 'triggerCache'
|
|
62
|
-
) {
|
|
63
|
-
let objectSchema = await getObjectSchema
|
|
64
|
-
.getLocalObjectSchemas(
|
|
65
|
-
_izContext,
|
|
66
|
-
[flowSchema.objType.objectType],
|
|
67
|
-
path.join(appPath, 'src/schemas')
|
|
68
|
-
)
|
|
69
|
-
.then(res => res.records[0]);
|
|
70
|
-
if (!objectSchema)
|
|
71
|
-
throw new NoRetryError('no objectSchema in local service');
|
|
72
|
-
for (const storageResource of Object.values(
|
|
73
|
-
objectSchema.storageResources
|
|
74
|
-
)) {
|
|
75
|
-
if (storageResource.storageType === STORAGE_TYPES.dynamoDB) {
|
|
76
|
-
tableName = storageResource.tableName;
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
let triggerType;
|
|
82
|
-
if (
|
|
83
|
-
flowSchema.statusType === 'triggerCache' &&
|
|
84
|
-
flowSchema.hasOwnProperty('triggerType')
|
|
85
|
-
) {
|
|
86
|
-
triggerType = flowSchema.triggerType;
|
|
87
|
-
}
|
|
88
|
-
let flowSchemaComplete = upperCase(flowSchema.flowTag);
|
|
89
|
-
|
|
90
|
-
return {
|
|
91
|
-
templatePath: templatePath,
|
|
92
|
-
templateData: {
|
|
93
|
-
statusType: flowSchema.statusType,
|
|
94
|
-
statusFieldTemplate,
|
|
95
|
-
storedCacheTemplate,
|
|
96
|
-
triggerCacheTemplate,
|
|
97
|
-
flowTag: flowSchema.flowTag,
|
|
98
|
-
functionName,
|
|
99
|
-
tableName,
|
|
100
|
-
flowSchemaComplete,
|
|
101
|
-
triggerType,
|
|
102
|
-
queueName: `${createFlowTypeConcat(_izContext, { serviceTag: (await import('yaml')).default.parse((await import('fs')).default.readFileSync(path.resolve(appPath, '../config/serverless.config.yml'), 'utf8'))?.main_config?.iz_serviceTag, flowTag: upperCase(flowSchema.flowTag) })}_Main`
|
|
103
|
-
},
|
|
104
|
-
setting: {
|
|
105
|
-
savePath:
|
|
106
|
-
// path.join(
|
|
107
|
-
// appPath,
|
|
108
|
-
// SOURCE_PATH.flowSchema,
|
|
109
|
-
// upperCase(flowSchema.flowTag),
|
|
110
|
-
// 'source/'
|
|
111
|
-
// ),
|
|
112
|
-
savePath.resourceYamlFlowSchemaFlowTag(appPath, flowSchema.flowTag),
|
|
113
|
-
saveFileName: `${functionName}_Main`,
|
|
114
|
-
fileExtension: '.js',
|
|
115
|
-
isAppend: false
|
|
116
|
-
}
|
|
117
|
-
};
|
|
118
|
-
}
|
|
119
|
-
export default createParamsForCreateSource;
|
|
@@ -1,89 +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
|
-
import { getObjectSchema } from '@izara_project/izara-core-library-service-schemas';
|
|
20
|
-
import dynamodbSharedLib from '@izara_project/izara-core-library-dynamodb';
|
|
21
|
-
import snsSharedLib from '@izara_project/izara-core-library-sns';
|
|
22
|
-
import sqsSharedLib from '@izara_project/izara-core-library-sqs';
|
|
23
|
-
import asyncFlowSharedLib from '@izara_project/izara-core-library-asynchronous-flow';
|
|
24
|
-
import callingFlowSharedLib from '@izara_project/izara-core-library-calling-flow';
|
|
25
|
-
import lambdaSharedLib from '@izara_project/izara-core-library-lambda';
|
|
26
|
-
import { lambda,sns,sqs } from '@izara_project/izara-core-library-external-request';
|
|
27
|
-
import { NoRetryError } from '@izara_project/izara-core-library-core';
|
|
28
|
-
import { utils } from '@izara_project/izara-core-library-service-schemas';
|
|
29
|
-
const { createFlowTypeConcat } = utils;
|
|
30
|
-
<% if (statusType === "triggerCache") { -%>
|
|
31
|
-
import { triggeredCacheSharedLibV2 } from '@izara_project/izara-core-library-trigger-cache';
|
|
32
|
-
<% } else if (statusType === "statusField") { -%>
|
|
33
|
-
import statusFieldSharedLib from '@izara_project/izara-core-library-status-field';
|
|
34
|
-
<% } else if (statusType === "storedCache") { -%>
|
|
35
|
-
import storedCacheSharedLib from '@izara_project/izara-core-library-stored-cache';
|
|
36
|
-
<% } -%>
|
|
37
|
-
|
|
38
|
-
//(<optionalRequire>)
|
|
39
|
-
//(</optionalRequire>)
|
|
40
|
-
/**
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
* description of function.
|
|
44
|
-
* @param {Object} _izContext
|
|
45
|
-
* @param {CorrelationIds} _izContext.correlationIds - property of _izContext
|
|
46
|
-
* @param {Logger} _izContext.logger - property of _izContext
|
|
47
|
-
* @param {Object} requestParams - request params
|
|
48
|
-
* @param {Object} requestParams.identifiers - identifiers for get data
|
|
49
|
-
* @param {Object} requestParams.additionalRequest - additionalRequest
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
* @returns {object} description of return value
|
|
53
|
-
*/
|
|
54
|
-
|
|
55
|
-
export default async function <%- functionName %> (
|
|
56
|
-
_izContext,
|
|
57
|
-
requestParams,
|
|
58
|
-
callingFlowConfig = {},
|
|
59
|
-
//(<additionalParams>)
|
|
60
|
-
//(</additionalParams>)
|
|
61
|
-
) {
|
|
62
|
-
|
|
63
|
-
try {
|
|
64
|
-
_izContext.logger.debug("<%- functionName %> _izContext", _izContext)
|
|
65
|
-
_izContext.logger.debug("<%- functionName %> requestParams", requestParams)
|
|
66
|
-
_izContext.logger.debug("<%- functionName %> callingFlowConfig", callingFlowConfig)
|
|
67
|
-
|
|
68
|
-
<% if (statusType === "statusField") { %>
|
|
69
|
-
<% include(statusFieldTemplate, { tableName:tableName, flowTag: flowTag }) %>
|
|
70
|
-
<% } else if (statusType === "storedCache") { %>
|
|
71
|
-
<% include(storedCacheTemplate, { tableName:tableName, flowSchemaComplete:flowSchemaComplete, flowTag }) %>
|
|
72
|
-
<% } else if (statusType === "triggerCache") { %>
|
|
73
|
-
<% include(triggerCacheTemplate, {
|
|
74
|
-
tableName: tableName,
|
|
75
|
-
flowSchemaComplete: flowSchemaComplete,
|
|
76
|
-
triggerType: triggerType,
|
|
77
|
-
flowTag,
|
|
78
|
-
queueName
|
|
79
|
-
}) %>
|
|
80
|
-
<% } %>
|
|
81
|
-
|
|
82
|
-
//(<endpointHook>)
|
|
83
|
-
//(</endpointHook>)
|
|
84
|
-
|
|
85
|
-
} catch (err) {
|
|
86
|
-
_izContext.logger.error('error WebSocketInvoke: ', err)
|
|
87
|
-
throw (err)
|
|
88
|
-
}
|
|
89
|
-
}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
//(<beforeCheckedStatusField>)
|
|
2
|
-
//(</beforeCheckedStatusField>)
|
|
3
|
-
|
|
4
|
-
let [status, flowStatusFieldRecord] = await statusFieldSharedLib.checkStatusField(
|
|
5
|
-
_izContext,
|
|
6
|
-
{
|
|
7
|
-
flowTag: "<%- flowTag %>",
|
|
8
|
-
serviceTag: process.env.iz_serviceTag
|
|
9
|
-
},
|
|
10
|
-
{
|
|
11
|
-
//(<identifiers>)
|
|
12
|
-
//(</identifiers>)
|
|
13
|
-
},
|
|
14
|
-
//(<errorsFounds>)
|
|
15
|
-
//(<errorsFounds>)
|
|
16
|
-
//(<overwriteUniqueRequestId>)
|
|
17
|
-
//(</overwriteUniqueRequestId>)
|
|
18
|
-
)
|
|
19
|
-
|
|
20
|
-
//(<afterCheckStatusField>)
|
|
21
|
-
//(</afterCheckStatusField>)
|
|
22
|
-
|
|
23
|
-
if (status !== "process") {
|
|
24
|
-
if (status === "error" || status === "complete") {
|
|
25
|
-
//(<afterValidateStatusField>)
|
|
26
|
-
//(</afterValidateStatusField>)
|
|
27
|
-
}
|
|
28
|
-
//(<checkStatusFieldHook>)
|
|
29
|
-
//(</checkStatusFieldHook>)
|
|
30
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
let [ cacheMainStatus, cacheMain, cacheExist ] = await storedCacheSharedLib.checkStoredCacheStatus(
|
|
2
|
-
_izContext,
|
|
3
|
-
"<%- tableName %>",
|
|
4
|
-
{
|
|
5
|
-
//(<keyValueStoredCacheTable>)
|
|
6
|
-
//(</keyValueStoredCacheTable>)
|
|
7
|
-
},
|
|
8
|
-
//(<additionalAttributesWhenCreateStoredCache>)
|
|
9
|
-
//(</additionalAttributesWhenCreateStoredCache>),
|
|
10
|
-
createFlowTypeConcat(_izContext,{flowTag: "<%- flowTag %>", serviceTag: process.env.iz_serviceTag}),
|
|
11
|
-
//(<storedCacheConfig>)
|
|
12
|
-
//(</storedCacheConfig>)
|
|
13
|
-
)
|
|
14
|
-
|
|
15
|
-
//(<afterCheckStoredCache>)
|
|
16
|
-
//(</afterCheckStoredCache>)
|
|
17
|
-
|
|
18
|
-
if (cacheMainStatus !== "process") {
|
|
19
|
-
if (cacheMainStatus === "error" || cacheMainStatus === "complete") {
|
|
20
|
-
//(<afterValidateStoredCacheStatus>)
|
|
21
|
-
//(</afterValidateStoredCacheStatus>)
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
//(<checkStoredCacheHook>)
|
|
25
|
-
//(</checkStoredCacheHook>)
|
|
26
|
-
}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
let [triggerCacheStatus, triggerCache] = await triggeredCacheSharedLibV2.checkTriggeredCacheV2(
|
|
2
|
-
_izContext,
|
|
3
|
-
{
|
|
4
|
-
serviceTag: process.env.iz_serviceTag,
|
|
5
|
-
flowTag: "<%- flowTag %>"
|
|
6
|
-
},
|
|
7
|
-
{
|
|
8
|
-
//(<identifiersTriggerCacheTable>)
|
|
9
|
-
//(</identifiersTriggerCacheTable>)
|
|
10
|
-
},
|
|
11
|
-
//(<additionalCheckTriggerCacheSetting>)
|
|
12
|
-
"", // overWriteUniqueRequestId
|
|
13
|
-
{}, //flowParams
|
|
14
|
-
false, // createIfNotHave
|
|
15
|
-
{} // triggerFlowIdentifiers
|
|
16
|
-
//(</additionalCheckTriggerCacheSetting>)
|
|
17
|
-
)
|
|
18
|
-
|
|
19
|
-
//(<afterCheckTriggerCache>)
|
|
20
|
-
//(</afterCheckTriggerCache>)
|
|
21
|
-
|
|
22
|
-
if (triggerCacheStatus !== "process") {
|
|
23
|
-
if (triggerCacheStatus === "error" || triggerCacheStatus === "complete") {
|
|
24
|
-
//(<afterValidateTriggerCacheStatus>)
|
|
25
|
-
//(</afterValidateTriggerCacheStatus>)
|
|
26
|
-
}
|
|
27
|
-
//(<checkTriggerCacheHook>)
|
|
28
|
-
//(</checkTriggerCacheHook>)
|
|
29
|
-
|
|
30
|
-
// send message to ProcessTriggerCache
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
//(<processTriggerCacheHook>)
|
|
34
|
-
//(</processTriggerCacheHook>)
|
|
35
|
-
let sendMessageToProcessTriggerCache = {
|
|
36
|
-
MessageBody: JSON.stringify(
|
|
37
|
-
//(<messageBody>)
|
|
38
|
-
//(</messageBody>)
|
|
39
|
-
),
|
|
40
|
-
QueueUrl: await sqsSharedLib.sqsQueueUrl(_izContext, "<%- queueName %>")
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
await sqs.sendMessage(_izContext, sendMessageToProcessTriggerCache)
|
|
44
|
-
_izContext.logger.debug("after send message to <%- queueName %>", sendMessageToProcessTriggerCache)
|
package/src/codeGenerators/app/src/generatedCode/Flow/FlowSchemas/templates/s3Legacy/index.js
DELETED
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
// Create S3 Component
|
|
2
|
-
import createFunctionYamlCreateObjectWebSocket from './upload/createObject/functionYaml/data.js';
|
|
3
|
-
import createHandlerCreateObjectWebSocket from './upload/createObject/handler/data.js';
|
|
4
|
-
import createMainFunctionCreateObjectWebSocket from './upload/createObject/mainFunction/data.js';
|
|
5
|
-
|
|
6
|
-
// Create PreSigned URL Component
|
|
7
|
-
// reservedLimit
|
|
8
|
-
import createReservedLimitFunctionYaml from './upload/preSignUrl/reservedLimit/functionYaml/data.js';
|
|
9
|
-
import createReservedLimitHandler from './upload/preSignUrl/reservedLimit/handler/data.js';
|
|
10
|
-
import createReservedLimitMainFunction from './upload/preSignUrl/reservedLimit/mainFunction/data.js';
|
|
11
|
-
import createReservedLimitQueueName from './upload/preSignUrl/reservedLimit/sqs/data.js';
|
|
12
|
-
// createPreSignUrl
|
|
13
|
-
import createPreSignUrlFunctionYaml from './upload/preSignUrl/createPreSignUrl/functionYaml/data.js';
|
|
14
|
-
import createPreSignUrlHandler from './upload/preSignUrl/createPreSignUrl/handler/data.js';
|
|
15
|
-
import createPreSignUrlMainFunction from './upload/preSignUrl/createPreSignUrl/mainFunction/data.js';
|
|
16
|
-
import createPreSignUrlQueueName from './upload/preSignUrl/createPreSignUrl/queue/data.js';
|
|
17
|
-
// Process After Upload S3
|
|
18
|
-
import createProcessAfterUploadS3FunctionYmlS3 from './upload/processFile/functionYml/HdrS3/data.js';
|
|
19
|
-
import createProcessAfterUploadS3HandlerS3 from './upload/processFile/handler/handlerS3/data.js';
|
|
20
|
-
import createProcessAfterUploadS3MainFunction from './upload/processFile/mainFunction/data.js';
|
|
21
|
-
// confirm After Upload S3
|
|
22
|
-
import createConfirmAfterUploadS3FunctionYaml from './upload/confirmReserved/functionYaml/data.js';
|
|
23
|
-
import createConfirmAfterUploadS3Handler from './upload/confirmReserved/handler/data.js';
|
|
24
|
-
import createConfirmAfterUploadS3MainFunction from './upload/confirmReserved/mainFunction/data.js';
|
|
25
|
-
import createConfirmAfterUploadS3Queue from './upload/confirmReserved/queue/data.js';
|
|
26
|
-
// Relate Resources
|
|
27
|
-
import createBucketS3 from './upload/relate/S3/data.js';
|
|
28
|
-
// Other Resources
|
|
29
|
-
import createReservedDataMainTable from './websocket/dynamoDb/ReservedTableData.js';
|
|
30
|
-
import createSnsTopicForUploadS3 from './upload/relate/sns-out/data.js';
|
|
31
|
-
|
|
32
|
-
//
|
|
33
|
-
import createFlowSchemaEndpointMainFunction from './flowSchemaMainFunction/data.js';
|
|
34
|
-
|
|
35
|
-
async function createS3Component(_izContext, flowSchema, appPath) {
|
|
36
|
-
const component = [
|
|
37
|
-
// * Create Object WebSocket
|
|
38
|
-
createFunctionYamlCreateObjectWebSocket(_izContext, flowSchema, appPath),
|
|
39
|
-
createHandlerCreateObjectWebSocket(_izContext, flowSchema, appPath),
|
|
40
|
-
createMainFunctionCreateObjectWebSocket(_izContext, flowSchema, appPath),
|
|
41
|
-
|
|
42
|
-
// * PreSigned URL WebSocket
|
|
43
|
-
// reservedLimit
|
|
44
|
-
await createReservedLimitFunctionYaml(_izContext, flowSchema, appPath),
|
|
45
|
-
createReservedLimitHandler(_izContext, flowSchema, appPath),
|
|
46
|
-
createReservedLimitMainFunction(_izContext, flowSchema, appPath),
|
|
47
|
-
...createReservedLimitQueueName(_izContext, appPath),
|
|
48
|
-
|
|
49
|
-
// createPreSignUrl
|
|
50
|
-
createPreSignUrlFunctionYaml(_izContext, flowSchema, appPath),
|
|
51
|
-
createPreSignUrlHandler(_izContext, flowSchema, appPath),
|
|
52
|
-
createPreSignUrlMainFunction(_izContext, flowSchema, appPath),
|
|
53
|
-
...createPreSignUrlQueueName(_izContext, appPath),
|
|
54
|
-
|
|
55
|
-
// * Process After Upload S3
|
|
56
|
-
createProcessAfterUploadS3FunctionYmlS3(_izContext, flowSchema, appPath),
|
|
57
|
-
createProcessAfterUploadS3HandlerS3(_izContext, flowSchema, appPath),
|
|
58
|
-
createProcessAfterUploadS3MainFunction(_izContext, flowSchema, appPath),
|
|
59
|
-
|
|
60
|
-
// * confirm After Upload S3
|
|
61
|
-
createConfirmAfterUploadS3FunctionYaml(_izContext, flowSchema, appPath),
|
|
62
|
-
createConfirmAfterUploadS3Handler(_izContext, flowSchema, appPath),
|
|
63
|
-
createConfirmAfterUploadS3MainFunction(_izContext, flowSchema, appPath),
|
|
64
|
-
...createConfirmAfterUploadS3Queue(_izContext, appPath),
|
|
65
|
-
|
|
66
|
-
// * Relate Resources
|
|
67
|
-
createBucketS3(_izContext, flowSchema, appPath),
|
|
68
|
-
|
|
69
|
-
// * Other Resources
|
|
70
|
-
...createReservedDataMainTable(_izContext, appPath),
|
|
71
|
-
...createSnsTopicForUploadS3(_izContext, flowSchema, appPath),
|
|
72
|
-
|
|
73
|
-
//
|
|
74
|
-
await createFlowSchemaEndpointMainFunction(_izContext, flowSchema, appPath)
|
|
75
|
-
];
|
|
76
|
-
|
|
77
|
-
return component.flat();
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
export default createS3Component;
|
|
@@ -1,129 +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
|
-
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
|
-
HANDLER,
|
|
31
|
-
RESOURCE_CLASSES,
|
|
32
|
-
SQS_RESOURCE,
|
|
33
|
-
SNS_RESOURCE,
|
|
34
|
-
SOURCE_PATH,
|
|
35
|
-
SAVE_FILE_NAME,
|
|
36
|
-
DYNAMO_RESOURCE,
|
|
37
|
-
LAMBDA_RESOURCE,
|
|
38
|
-
SOURCE_GENERATE_IAM_ROLE,
|
|
39
|
-
ACTIONS
|
|
40
|
-
} = consts;
|
|
41
|
-
|
|
42
|
-
const {
|
|
43
|
-
defaultIamRolePerAction,
|
|
44
|
-
createIamRole,
|
|
45
|
-
resourceNames,
|
|
46
|
-
shortNameHandler
|
|
47
|
-
} = libs;
|
|
48
|
-
|
|
49
|
-
const templatePath = path.join(__dirname, 'template.ejs');
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* receive objectSchema
|
|
53
|
-
*
|
|
54
|
-
* @param {Object} flowSchema
|
|
55
|
-
* @return {{ templatePath, templateData, setting } }
|
|
56
|
-
*/
|
|
57
|
-
|
|
58
|
-
function createSourceParams(_izContext, flowSchema, appPath) {
|
|
59
|
-
let functionName = 'ConfirmNewReserved';
|
|
60
|
-
let handlerType = upperCase(HANDLER.hdrSqs);
|
|
61
|
-
let additionalResourcePermission = defaultIamRolePerAction();
|
|
62
|
-
|
|
63
|
-
additionalResourcePermission.push(
|
|
64
|
-
createIamRole(
|
|
65
|
-
{
|
|
66
|
-
[RESOURCE_CLASSES.sqs]: [
|
|
67
|
-
SQS_RESOURCE.receiveMessage,
|
|
68
|
-
SQS_RESOURCE.sendMessage,
|
|
69
|
-
SQS_RESOURCE.deleteMessage,
|
|
70
|
-
SQS_RESOURCE.getQueueAttributes
|
|
71
|
-
]
|
|
72
|
-
},
|
|
73
|
-
[
|
|
74
|
-
resourceNames(RESOURCE_CLASSES.sqs, functionName + handlerType),
|
|
75
|
-
resourceNames(RESOURCE_CLASSES.sqs, functionName + 'DLQ')
|
|
76
|
-
]
|
|
77
|
-
),
|
|
78
|
-
createIamRole(
|
|
79
|
-
{
|
|
80
|
-
[RESOURCE_CLASSES.dynamoDbTable]: [
|
|
81
|
-
DYNAMO_RESOURCE.query,
|
|
82
|
-
DYNAMO_RESOURCE.deleteItem,
|
|
83
|
-
DYNAMO_RESOURCE.updateItem,
|
|
84
|
-
DYNAMO_RESOURCE.putItem
|
|
85
|
-
]
|
|
86
|
-
},
|
|
87
|
-
[resourceNames(RESOURCE_CLASSES.dynamoDbTable, 'ReservedDataMain')]
|
|
88
|
-
),
|
|
89
|
-
createIamRole(
|
|
90
|
-
{
|
|
91
|
-
[RESOURCE_CLASSES.lambda]: [LAMBDA_RESOURCE.invokeFunction],
|
|
92
|
-
[RESOURCE_CLASSES.sns]: [SNS_RESOURCE.publish]
|
|
93
|
-
},
|
|
94
|
-
[
|
|
95
|
-
resourceNames(
|
|
96
|
-
RESOURCE_CLASSES.lambda,
|
|
97
|
-
upperCase(ACTIONS.get) + upperCase(HANDLER.hdrInv)
|
|
98
|
-
),
|
|
99
|
-
resourceNames(RESOURCE_CLASSES.sns, upperCase(ACTIONS.update) + '_In')
|
|
100
|
-
]
|
|
101
|
-
)
|
|
102
|
-
);
|
|
103
|
-
|
|
104
|
-
return {
|
|
105
|
-
templatePath: templatePath,
|
|
106
|
-
templateData: {
|
|
107
|
-
functionName,
|
|
108
|
-
handlerType,
|
|
109
|
-
functionNameConfig: functionName + upperCase(handlerType),
|
|
110
|
-
resourceLocation: path.join(
|
|
111
|
-
SOURCE_PATH.resourceLocationWebSocket,
|
|
112
|
-
flowSchema.flowTag,
|
|
113
|
-
'source/'
|
|
114
|
-
),
|
|
115
|
-
additionalResourcePermission,
|
|
116
|
-
functionNameConfig:
|
|
117
|
-
upperCase(functionName) + upperCase(shortNameHandler(handlerType)),
|
|
118
|
-
roleName: SOURCE_GENERATE_IAM_ROLE.FlowSchemaUploadS3Role
|
|
119
|
-
},
|
|
120
|
-
setting: {
|
|
121
|
-
saveFileName: SAVE_FILE_NAME.flowSchemaYaml,
|
|
122
|
-
savePath: path.join(appPath, SOURCE_PATH.appYaml),
|
|
123
|
-
fileExtension: '.yml',
|
|
124
|
-
isAppend: true
|
|
125
|
-
}
|
|
126
|
-
};
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
export default createSourceParams;
|
|
@@ -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}<%- firstLetterUpperCase(functionName) %><%- firstLetterUpperCase(handlerType) %>"]}}} # functionName of callingFlow
|
|
14
|
-
- body: {"MessageAttributes":{"callingFlow":{"Value":[{"exists":false}]}}}
|
|
15
|
-
<%_ function firstLetterUpperCase(text){
|
|
16
|
-
return text.charAt(0).toUpperCase() + text.slice(1)
|
|
17
|
-
} _%>
|