@izara_project/izara-market-library-service-schemas 1.0.81 → 1.0.82

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.
Files changed (30) hide show
  1. package/package.json +11 -10
  2. package/src/GenerateCodeLibs/src/GenerateCodeLibs.js +2 -2
  3. package/src/MainLibs/src/Utils.js +2 -2
  4. package/src/reStructure/GenerateTests.js +4 -3
  5. package/src/reStructure/TemplateData/IntTest/generateTests/tests/data.js +1 -1
  6. package/src/reStructure/TemplateData/IntTest/libs/libs.js +1 -0
  7. package/src/reStructure/TemplateData/IntTest/upload/uploadIntTest.js +43 -23
  8. package/src/reStructure/TemplateData/flowSchema/components/upload/createObject/functionYaml/data.js +2 -1
  9. package/src/reStructure/TemplateData/flowSchema/components/upload/relate/libs/template.ejs +1 -1
  10. package/src/reStructure/TemplateData/flowSchema/components/websocket/connect/handler/template.ejs +3 -3
  11. package/src/reStructure/TemplateData/flowSchema/flowSchemaMainFunction/data.js +4 -3
  12. package/src/reStructure/TemplateData/flowSchema/flowSchemaMainFunction/template.ejs +1 -4
  13. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaComponent/handler/template.ejs +1 -2
  14. package/src/reStructure/TemplateData/flowSchema/generateTemplateData.js +1 -1
  15. package/src/reStructure/TemplateData/flowSchema/templateByStatusType/triggerCacheTemplate.ejs +30 -24
  16. package/src/reStructure/TemplateData/flowSchema/triggerCacheComponent/checkTriggerCacheComplete/mainFunction/template.ejs +3 -1
  17. package/src/reStructure/TemplateData/flowSchema/triggerCacheComponent/processTriggerCache/functionYaml/data.js +7 -3
  18. package/src/reStructure/TemplateData/flowSchema/triggerCacheComponent/processTriggerCache/functionYaml/template.ejs +1 -0
  19. package/src/reStructure/TemplateData/flowSchema/triggerCacheComponent/processTriggerCache/handler/data.js +8 -4
  20. package/src/reStructure/TemplateData/flowSchema/triggerCacheComponent/processTriggerCache/mainFunction/data.js +7 -7
  21. package/src/reStructure/TemplateData/flowSchema/triggerCacheComponent/triggerCacheComplete/mainFunction/template.ejs +3 -1
  22. package/src/reStructure/TemplateData/flowSchema/triggerCacheComponent/triggerCacheQueue/data.js +9 -5
  23. package/src/reStructure/TemplateData/flowSchema/triggerCacheComponent/triggerCacheQueue/template.ejs +12 -6
  24. package/src/reStructure/TemplateData/perActionComplete/create/mainFunction/template.ejs +3 -0
  25. package/src/reStructure/TemplateData/relationshipPerAction/changeRelationship/action/functionYaml/data.js +1 -1
  26. package/src/reStructure/TemplateData/relationshipPerAction/create/action/functionYaml/data.js +1 -1
  27. package/src/reStructure/TemplateData/relationshipPerAction/delete/action/functionYaml/data.js +1 -1
  28. package/src/reStructure/TemplateData/relationshipPerAction/get/action/functionYaml/data.js +1 -1
  29. package/src/reStructure/TemplateData/relationshipPerAction/moveRelationship/action/functionYaml/data.js +1 -1
  30. package/src/reStructure/TemplateData/relationshipPerAction/update/action/functionYaml/data.js +1 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@izara_project/izara-market-library-service-schemas",
3
- "version": "1.0.81",
3
+ "version": "1.0.82",
4
4
  "description": "Schemas for Izara Market project",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -21,24 +21,25 @@
21
21
  },
22
22
  "type": "module",
23
23
  "dependencies": {
24
+ "@izara_project/izara-core-library-asynchronous-flow": "^1.0.19",
24
25
  "@izara_project/izara-core-library-calling-flow": "^1.0.4",
25
- "@izara_project/izara-core-library-core": "^1.0.28",
26
- "@izara_project/izara-core-library-dynamodb": "^1.0.12",
27
- "@izara_project/izara-core-library-external-request": "^1.0.22",
28
- "@izara_project/izara-core-library-graph-service": "1.0.16",
26
+ "@izara_project/izara-core-library-core": "^1.0.31",
27
+ "@izara_project/izara-core-library-dynamodb": "^1.0.13",
28
+ "@izara_project/izara-core-library-external-request": "^1.0.23",
29
+ "@izara_project/izara-core-library-graph-service": "1.0.17",
29
30
  "@izara_project/izara-core-library-lambda": "^1.0.6",
30
31
  "@izara_project/izara-core-library-logger": "^1.0.8",
31
- "@izara_project/izara-core-library-s3": "^1.0.3",
32
- "@izara_project/izara-core-library-service-schemas": "^1.0.102",
32
+ "@izara_project/izara-core-library-s3": "^1.0.5",
33
+ "@izara_project/izara-core-library-service-schemas": "^1.0.104",
33
34
  "@izara_project/izara-core-library-sns": "^1.0.7",
34
35
  "@izara_project/izara-core-library-sqs": "^1.0.5",
35
36
  "@izara_project/izara-shared": "^1.0.126",
36
- "@izara_project/izara-shared-core": "^1.0.6",
37
- "@izara_project/izara-shared-service-schemas": "^1.0.33",
37
+ "@izara_project/izara-shared-core": "^1.0.8",
38
+ "@izara_project/izara-shared-service-schemas": "^1.0.35",
38
39
  "ejs": "^3.1.10",
39
40
  "js-beautify": "^1.15.4",
40
41
  "lodash": "^4.17.21",
41
42
  "object-hash": "^3.0.0",
42
- "yaml": "^2.8.1"
43
+ "yaml": "^2.8.2"
43
44
  }
44
45
  }
@@ -19,13 +19,13 @@ along with this program.If not, see < http://www.gnu.org/licenses/>.
19
19
 
20
20
  import lodash from 'lodash';
21
21
  import { objectHash as hash } from '@izara_project/izara-shared-core';
22
- import { NoRetryError, inMemoryCacheLib } from '@izara_project/izara-core-library-core';
22
+ import { NoRetryError, inMemoryCacheLib, validator as validateObject } from '@izara_project/izara-core-library-core';
23
23
  import { sns, sqs } from '@izara_project/izara-core-library-external-request';
24
24
  import { getObjectSchema, validator as validatorSchema, serviceConfig, utils, consts as coreConsts, explodedReqParams, deliminatorTree } from '@izara_project/izara-core-library-service-schemas'
25
25
  import Logger from "@izara_project/izara-core-library-logger";
26
26
 
27
27
  import { validateObjType } from '@izara_project/izara-shared-service-schemas';
28
- import { validator as validateObject } from "@izara_project/izara-core-library-core"
28
+
29
29
  // core libs
30
30
  import dynamodbSharedLib from '@izara_project/izara-core-library-dynamodb';
31
31
  import asyncFlowSharedLib from '@izara_project/izara-core-library-asynchronous-flow'
@@ -39,8 +39,8 @@ function checkOverWriteGenerateMainFunction(objectSchema, action) {
39
39
  return overWriteStatus
40
40
  }
41
41
 
42
- function getLocalConfig(srcPath, params) {
43
- const configPath = path.join(srcPath, '../config/serverless.config.yml');
42
+ function getLocalConfig(params) {
43
+ const configPath = path.join(process.cwd(), '../config/serverless.config.yml');
44
44
  const serverlessConfig = fs.readFileSync(configPath, 'utf8');
45
45
  const config = yaml.parse(serverlessConfig);
46
46
  const returnConfig = config.main_config[params];
@@ -30,10 +30,11 @@ import generateTest from './TemplateData/IntTest/generateTests/generateTemplate.
30
30
 
31
31
  import lib from '../reStructure/TemplateData/IntTest/libs/libs.js';
32
32
  const { getLocalConfig } = lib;
33
+ import uploadLib from '../reStructure/TemplateData/IntTest/upload/uploadIntTest.js'
33
34
  async function generateCodeWithTemplate(_izContext, savePath, settings) {
34
35
  _izContext.logger.debug("START", { savePath, settings })
35
36
  try {
36
-
37
+ const serviceTag = getLocalConfig("iz_serviceTag")
37
38
  let packagePath = path.join(__dirname, "../../")
38
39
  // console.log({ packagePath });
39
40
  // --------- Prepare path -------------
@@ -108,10 +109,10 @@ async function generateCodeWithTemplate(_izContext, savePath, settings) {
108
109
  console.log('Generated all source files successfully');
109
110
 
110
111
  console.log("upload file to S3")
111
- const intTestPath = join(saveFilePath, `../../src/generateIntegrationTest/${getLocalConfig("iz_serviceTag")}`)
112
+ const intTestPath = join(saveFilePath, `../../src/generateIntegrationTest/${serviceTag}`)
112
113
  console.log({ intTestPath })
113
114
 
114
- // uploadLib(intTestPath, settings)
115
+ await uploadLib(intTestPath, { s3Prefix: settings, serviceTag: serviceTag })
115
116
 
116
117
 
117
118
  // exec(`bash ${ path.join(packagePath, "./frontEnd/NpmBash.bash") } `, (error, stdout, stderr) => {
@@ -153,7 +153,7 @@ async function data(_izContext, allIntTestConfig, srcPath) {
153
153
  }
154
154
  }
155
155
 
156
- Object.assign(baseIntTest, { stage: stages })
156
+ Object.assign(baseIntTest, { stages: stages })
157
157
 
158
158
  // console.log("baseIntTest", JSON.stringify(baseIntTest, null, 2));
159
159
 
@@ -4,6 +4,7 @@ import yaml from "yaml";
4
4
  import fs from 'fs';
5
5
  import { getObjectSchema } from '@izara_project/izara-core-library-service-schemas';
6
6
  const { getDataFromPath } = getObjectSchema;
7
+
7
8
  function lowercaseFirst(str) {
8
9
  if (!str) return "";
9
10
  return str[0].toLowerCase() + str.slice(1);
@@ -25,36 +25,56 @@ import Logger from "@izara_project/izara-core-library-logger";
25
25
 
26
26
  const _izContext = { Logger }
27
27
 
28
- async function uploadFolder(folderPath, s3Prefix) {
29
- let objectToUploads = [];
30
- const entries = fs.readdirSync(folderPath, { withFileTypes: true });
31
- for (const entry of entries) {
32
- const fullPath = path.join(folderPath, entry.name);
33
- const s3Key = path.join(s3Prefix, entry.name).replace(/\\/g, "/"); // path for user upload
34
-
35
- if (entry.isDirectory()) {
36
- await uploadFolder(fullPath, s3Key);
37
- } else {
28
+ async function uploadFolder(folderPath, settings) {
29
+
30
+ try {
31
+
32
+ const files = getAllFiles(folderPath);
33
+ console.log({ files })
34
+ for (const filePath of files) {
35
+ const fileContent = fs.readFileSync(filePath);
36
+ const index = filePath.indexOf(settings.serviceTag);
37
+
38
+ let relativePath;
39
+ if (index !== -1) {
40
+ relativePath = filePath.substring(index);
41
+ } else {
42
+ relativePath = path.basename(filePath);
43
+ }
38
44
 
39
- const fileStream = fs.createReadStream(fullPath);
45
+ let s3Key = path.join('test_config', settings.s3Prefix, relativePath).split(path.sep).join('/');
40
46
  const params = {
41
- Bucket: "integrationtest-config-us-east-2",
42
- Key: `test_config/${s3Key}`,
43
- Body: fileStream,
47
+ Bucket: 'integrationtest-config-us-east-2',
48
+ Key: s3Key,
49
+ Body: fileContent,
50
+ ContentType: 'application/json'
44
51
  };
45
52
 
46
- objectToUploads.push(s3.putObjectS3(_izContext, params));
53
+ await s3.putObjectS3(_izContext, params)
47
54
 
48
- try {
49
- await Promise.all(objectToUploads)
50
- console.log("uploadComplete to", s3Key)
51
- // console.log("Upload-Succuss:", s3Key, "ETag:", result.ETag);
52
- } catch (err) {
53
- // console.error("Upload-Failed:", s3Key, err);
54
- console.log("Upload-Failed");
55
- }
56
55
  }
56
+
57
+ } catch (err) {
58
+ console.error("Upload Failed:", err);
57
59
  }
58
60
  }
59
61
 
62
+ function getAllFiles(dirPath, filePaths) {
63
+ const files = fs.readdirSync(dirPath);
64
+
65
+ filePaths = filePaths || [];
66
+
67
+ files.forEach(function (file) {
68
+ const fullPath = path.join(dirPath, file);
69
+
70
+ if (fs.statSync(fullPath).isDirectory()) {
71
+ filePaths = getAllFiles(fullPath, filePaths);
72
+ } else {
73
+ filePaths.push(fullPath);
74
+ }
75
+ });
76
+
77
+ return filePaths;
78
+ }
79
+
60
80
  export default uploadFolder;
@@ -36,7 +36,8 @@ const {
36
36
  SAVE_FILE_NAME,
37
37
  DYNAMO_RESOURCE,
38
38
  SOURCE_GENERATE_IAM_ROLE,
39
- ACTIONS
39
+ ACTIONS,
40
+ FUNCTION_NAME
40
41
  } = consts;
41
42
 
42
43
  const templatePath = path.join(__dirname, 'template.ejs')
@@ -21,7 +21,7 @@ import { lambda } from '@izara_project/izara-core-library-external-request';
21
21
  import { ApiGatewayManagementApiClient, PostToConnectionCommand } from "@aws-sdk/client-apigatewaymanagementapi";
22
22
  import { objectHash as hash } from '@izara_project/izara-shared-core';
23
23
 
24
- const { NoRetryError, inMemoryCacheLib } = require('@izara_project/izara-core-library-core');
24
+ import { NoRetryError, inMemoryCacheLib } from '@izara_project/izara-core-library-core';
25
25
 
26
26
  const client = new ApiGatewayManagementApiClient({
27
27
  endpoint: `https://${process.env.iz_webSocketEndpoint}`
@@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
18
18
  'use strict';
19
19
 
20
20
  import dynamodbSharedLib from '@izara_project/izara-core-library-dynamodb';
21
- import { middlewareHandler as middleware } from "@izara_project/izara-middleware";
21
+ import { middlewareHandler as middleware, response } from "@izara_project/izara-middleware";
22
22
 
23
23
  export const main = middleware.wrap(async (event, context) => {
24
24
 
@@ -63,10 +63,10 @@ export const main = middleware.wrap(async (event, context) => {
63
63
  }
64
64
 
65
65
 
66
- return (izara.response.webSocketSuccess());
66
+ return (response.webSocketSuccess());
67
67
 
68
68
  } catch (err) {
69
69
  event._izContext.logger.error('Error, WebSocketConnect: ', err);
70
- return (izara.response.failure(err));
70
+ return (response.failure(err));
71
71
  }
72
72
  });
@@ -22,11 +22,11 @@ const __filename = fileURLToPath(import.meta.url);
22
22
  const __dirname = path.dirname(__filename);
23
23
 
24
24
  import { NoRetryError } from '@izara_project/izara-core-library-core';
25
- import { getObjectSchema } from '@izara_project/izara-core-library-service-schemas';
26
-
25
+ import { getObjectSchema, utils as coreUtils } from '@izara_project/izara-core-library-service-schemas';
26
+ const { createFlowTypeConcat } = coreUtils
27
27
  import { consts, utils } from '../../../../MainLibs/index.js';
28
28
  const { SOURCE_PATH, STORAGE_TYPES } = consts;
29
- const { firstLetterUpperCase: upperCase } = utils;
29
+ const { firstLetterUpperCase: upperCase, getLocalConfig } = utils;
30
30
 
31
31
  const templatePath = path.join(__dirname, "template.ejs");
32
32
  const statusFieldTemplate = path.join(__dirname, "../templateByStatusType/statusFieldTemplate.ejs")
@@ -77,6 +77,7 @@ async function createParamsForCreateSource(_izContext, flowSchema, srcPath) {
77
77
  tableName,
78
78
  flowSchemaComplete,
79
79
  triggerType,
80
+ queueName: `${createFlowTypeConcat(_izContext, { serviceTag: getLocalConfig("iz_serviceTag"), flowTag: flowSchema.flowTag })}_Main`
80
81
  },
81
82
  setting: {
82
83
  savePath: path.join(srcPath, SOURCE_PATH.flowSchema, upperCase(flowSchema.flowTag), "source/"),
@@ -30,11 +30,7 @@ import { NoRetryError } from '@izara_project/izara-core-library-core';
30
30
  import { utils} from '@izara_project/izara-core-library-service-schemas';
31
31
  const { createFlowTypeConcat } = utils;
32
32
  <% if (statusType === "triggerCache") { -%>
33
- <<<<<<< HEAD
34
- import triggeredCacheSharedLibV2 from '@izara_project/izara-core-library-trigger-cache';
35
- =======
36
33
  import { triggeredCacheSharedLibV2 } from '@izara_project/izara-core-library-trigger-cache';
37
- >>>>>>> 80dda49 (- fix bug: fix template for triggerCahce flowSchema, main function and handler)
38
34
  <% } else if (statusType === "statusField") { -%>
39
35
  import statusFieldSharedLib from '@izara_project/izara-core-library-status-field';
40
36
  <% } else if (statusType === "storedCache") { -%>
@@ -82,6 +78,7 @@ export default async function <%- functionName %> (
82
78
  flowSchemaComplete: flowSchemaComplete,
83
79
  triggerType: triggerType,
84
80
  flowTag,
81
+ queueName
85
82
  }) %>
86
83
  <% } %>
87
84
 
@@ -17,11 +17,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
17
17
 
18
18
  'use strict';
19
19
 
20
- import { middlewareHandler as middleware, validatorSchema } from "@izara_project/izara-middleware";
20
+ import { middlewareHandler as middleware, validatorSchema, consts } from "@izara_project/izara-middleware";
21
21
  import dynamodbSharedLib from '@izara_project/izara-core-library-dynamodb';
22
22
  import callingFlowSharedLib from '@izara_project/izara-core-library-calling-flow';
23
23
  import { objectHash as hash } from '@izara_project/izara-shared-core';
24
- import consts from '@izara_project/izara-middleware';
25
24
  import { postToConnection } from '../../../libs/source/GenerateCodeLibs.js';
26
25
  import <%- functionName %> from './<%- functionName %>_Main.js';
27
26
  import { utils} from "@izara_project/izara-core-library-service-schemas";
@@ -461,7 +461,7 @@ async function generateCodeWithTemplate(_izContext, objSchemaPath) {
461
461
  const functionYaml = (await Promise.all(Object.entries(createFlowSchemaTriggerCacheFunctionYaml).map(([type, functionYaml]) => functionYaml(_izContext, flowSchema, saveFilePath)))).flat();
462
462
  const mainFunction = Object.entries(createFlowSchemaTriggerCacheMainFunction).flatMap(([type, mainFunction]) => mainFunction(_izContext, flowSchema, saveFilePath));
463
463
  const handler = Object.entries(createFlowSchemaTriggerCacheHandler).flatMap(([type, handler]) => handler(_izContext, flowSchema, saveFilePath));
464
- const queue = createFlowSchemaTriggerCacheQueue(flowSchema, saveFilePath);
464
+ const queue = createFlowSchemaTriggerCacheQueue(_izContext, flowSchema, saveFilePath);
465
465
  // console.log("functionYaml", JSON.stringify(...functionYaml, null, 2))
466
466
  createSourceParams.push(...functionYaml, ...mainFunction, ...handler, ...queue)
467
467
  // console.log("Generate triggerCache component")
@@ -1,20 +1,20 @@
1
- let [triggerCacheStatus, triggerCache] = await triggeredCacheSharedLib.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
- )
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
18
 
19
19
  //(<afterCheckTriggerCache>)
20
20
  //(</afterCheckTriggerCache>)
@@ -28,11 +28,17 @@ if (triggerCacheStatus !== "process") {
28
28
  //(</checkTriggerCacheHook>)
29
29
 
30
30
  // send message to ProcessTriggerCache
31
- let sendMessageToProcessTriggerCache = {
32
- MessageBody: JSON.stringify(
33
- //(<messageBody>)
34
- //(</messageBody>)
35
- ),
36
- QueueUrl: await sqsSharedLib.sqsQueueUrl(_izContext, "ProcessTriggerCache<%- flowTag %>HdrSqs")
37
- }
38
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)
@@ -19,6 +19,8 @@ along with this program. If not, see
19
19
  'use strict';
20
20
 
21
21
  const { getObjectSchema } = require('@izara_project/izara-core-library-service-schemas');
22
+ import { triggeredCacheSharedLibV2 } from '@izara_project/izara-core-library-trigger-cache';
23
+
22
24
  //(<optionalRequire>)
23
25
  //(</optionalRequire>)
24
26
  /**
@@ -58,7 +60,7 @@ export default async function <%- functionName %> (
58
60
  serviceTag: topicName[0]
59
61
  })
60
62
 
61
- let checkTriggerCache = await triggeredCacheSharedLib.checkTriggeredCacheV2(
63
+ let checkTriggerCache = await triggeredCacheSharedLibV2.checkTriggeredCacheV2(
62
64
  _izContext,
63
65
  { // flowType
64
66
  serviceTag: topicName[0],
@@ -21,7 +21,8 @@ import { fileURLToPath } from 'url';
21
21
  const __filename = fileURLToPath(import.meta.url);
22
22
  const __dirname = path.dirname(__filename);;
23
23
  import { NoRetryError } from '@izara_project/izara-core-library-core';
24
- import { getObjectSchema } from '@izara_project/izara-core-library-service-schemas';
24
+ import { getObjectSchema, utils as coreUtils } from '@izara_project/izara-core-library-service-schemas';
25
+ const { createFlowTypeConcat } = coreUtils;
25
26
  import { consts, utils } from '../../../../../../MainLibs/index.js';
26
27
 
27
28
  const {
@@ -38,7 +39,7 @@ const {
38
39
  shortNameHandler,
39
40
  STORAGE_TYPES
40
41
  } = consts;
41
- const { firstLetterLowerCase: lowerCase, firstLetterUpperCase: upperCase } = utils;
42
+ const { firstLetterLowerCase: lowerCase, firstLetterUpperCase: upperCase, getLocalConfig } = utils;
42
43
  const templatePath = path.join(__dirname, './template.ejs')
43
44
 
44
45
  /**
@@ -55,9 +56,12 @@ async function data(_izContext, flowSchema, srcPath) {
55
56
 
56
57
  async function createSourceParams(_izContext, flowSchema, srcPath) {
57
58
  let functionName = "ProcessTriggerCache" + upperCase(flowSchema.flowTag)
59
+ // let functionName = createFlowTypeConcat(_izContext, { serviceTag: getLocalConfig("iz_serviceTag"), flowTag: upperCase(flowSchema.flowTag) })
58
60
  let handlerType = upperCase(HANDLER.hdrSqs)
59
61
  let additionalResourcePermission = defaultIamRolePerAction();
60
- let queueName = "ProcessTriggerCache" + upperCase(flowSchema.flowTag) + handlerType;
62
+ // let queueName = "ProcessTriggerCache" + upperCase(flowSchema.flowTag) + handlerType;
63
+ let queueName = `${createFlowTypeConcat(_izContext, { serviceTag: getLocalConfig("iz_serviceTag"), flowTag: upperCase(flowSchema.flowTag) })}_Main`
64
+
61
65
 
62
66
  additionalResourcePermission.push(
63
67
  createIamRole(
@@ -5,6 +5,7 @@
5
5
  role: <%- roleName %>Role
6
6
  #<#<%- functionName %><%- handlerType %>FunctionSetting#>
7
7
  #<#/<%- functionName %><%- handlerType %>FunctionSetting#>
8
+ events:
8
9
  - sqs:
9
10
  arn: arn:aws:sqs:${self:custom.iz_region}:${self:custom.iz_accountId}:${self:custom.iz_resourcePrefix}<%- queueName %>
10
11
  batchSize: 10
@@ -16,17 +16,20 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
16
16
  */
17
17
 
18
18
  'use strict';
19
- import path from 'path';;
19
+ import path from 'path';
20
20
  import { fileURLToPath } from 'url';
21
21
  const __filename = fileURLToPath(import.meta.url);
22
- const __dirname = path.dirname(__filename);;
22
+ const __dirname = path.dirname(__filename);
23
+ import { utils as coreUtils } from '@izara_project/izara-core-library-service-schemas';
24
+ const { createFlowTypeConcat } = coreUtils;
25
+
23
26
  import { consts, utils } from '../../../../../../MainLibs/index.js';
24
27
 
25
28
  const {
26
29
  SOURCE_PATH,
27
30
  HANDLER,
28
31
  } = consts;
29
- const { firstLetterLowerCase: lowerCase, firstLetterUpperCase: upperCase } = utils;
32
+ const { firstLetterLowerCase: lowerCase, firstLetterUpperCase: upperCase, getLocalConfig } = utils;
30
33
  const templatePath = path.join(__dirname, 'template.ejs');
31
34
 
32
35
  /**
@@ -43,8 +46,9 @@ function data(_izContext, flowSchema, srcPath) {
43
46
 
44
47
  function createSourceParams(_izContext, flowSchema, srcPath) {
45
48
  let functionName = "ProcessTriggerCache" + upperCase(flowSchema.flowTag)
49
+ // let functionName = createFlowTypeConcat(_izContext, { serviceTag: getLocalConfig("iz_serviceTag"), flowTag: upperCase(flowSchema.flowTag) })
46
50
  let handlerType = upperCase(HANDLER.hdrSqs)
47
- let queueName = "ProcessTriggerCache" + upperCase(flowSchema.flowTag) + handlerType;
51
+ let queueName = `${createFlowTypeConcat(_izContext, { serviceTag: getLocalConfig("iz_serviceTag"), flowTag: upperCase(flowSchema.flowTag) })}_Main`
48
52
 
49
53
 
50
54
  return {
@@ -16,16 +16,19 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
16
16
  */
17
17
 
18
18
  'use strict';
19
- import path from 'path';;
19
+ import path from 'path';
20
20
  import { fileURLToPath } from 'url';
21
21
  const __filename = fileURLToPath(import.meta.url);
22
- const __dirname = path.dirname(__filename);;
22
+ const __dirname = path.dirname(__filename);
23
+ import { utils as coreUtils } from '@izara_project/izara-core-library-service-schemas';
24
+ const { createFlowTypeConcat } = coreUtils;
25
+
23
26
  import { consts, utils } from '../../../../../../MainLibs/index.js';
24
27
  const {
25
28
  SOURCE_PATH,
26
29
  HANDLER,
27
30
  } = consts;
28
- const { firstLetterLowerCase: lowerCase, firstLetterUpperCase: upperCase } = utils;
31
+ const { firstLetterLowerCase: lowerCase, firstLetterUpperCase: upperCase, getLocalConfig } = utils;
29
32
  const templatePath = path.join(__dirname, './template.ejs')
30
33
 
31
34
  /**
@@ -42,15 +45,12 @@ function data(_izContext, flowSchema, srcPath) {
42
45
 
43
46
  function createSourceParams(_izContext, flowSchema, srcPath) {
44
47
  let functionName = "ProcessTriggerCache" + upperCase(flowSchema.flowTag)
45
- let handlerType = upperCase(HANDLER.hdrSqs)
46
- let queueName = "ProcessTriggerCache" + upperCase(flowSchema.flowTag) + handlerType;
47
-
48
+ // let functionName = createFlowTypeConcat(_izContext, { serviceTag: getLocalConfig("iz_serviceTag"), flowTag: upperCase(flowSchema.flowTag) })
48
49
 
49
50
  return {
50
51
  templatePath: templatePath,
51
52
  templateData: {
52
53
  functionName,
53
- queueName
54
54
  },
55
55
  setting: {
56
56
  savePath: path.join(srcPath, SOURCE_PATH.flowSchema, upperCase(flowSchema.flowTag), 'source/'),
@@ -18,6 +18,8 @@ along with this program. If not, see
18
18
 
19
19
  'use strict';
20
20
 
21
+ import { triggeredCacheSharedLibV2 } from '@izara_project/izara-core-library-trigger-cache';
22
+
21
23
  //(<optionalRequire>)
22
24
  //(</optionalRequire>)
23
25
  /**
@@ -48,7 +50,7 @@ export default async function <%- functionName %>(
48
50
  _izContext.logger.debug("<%- functionName %> requestParams", requestParams)
49
51
  _izContext.logger.debug("<%- functionName %> callingFlowConfig", callingFlowConfig)
50
52
 
51
- let checkTriggerResetedV2 = await triggeredCacheSharedLib.checkTriggerResetedV2(
53
+ let checkTriggerResetedV2 = await triggeredCacheSharedLibV2.checkTriggerResetedV2(
52
54
  _izContext,
53
55
  { // flowType
54
56
  serviceTag: process.env.iz_serviceTag,
@@ -17,10 +17,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
17
17
 
18
18
  'use strict';
19
19
 
20
- import path from 'path';;
20
+ import path from 'path';
21
21
  import { fileURLToPath } from 'url';
22
22
  const __filename = fileURLToPath(import.meta.url);
23
- const __dirname = path.dirname(__filename);;
23
+ const __dirname = path.dirname(__filename);
24
+ import { utils as coreUtils } from '@izara_project/izara-core-library-service-schemas';
25
+ const { createFlowTypeConcat } = coreUtils;
24
26
  import { consts, utils } from '../../../../../MainLibs/index.js';
25
27
 
26
28
  const {
@@ -29,7 +31,7 @@ const {
29
31
  SAVE_FILE_NAME
30
32
  } = consts;
31
33
 
32
- const { firstLetterLowerCase: lowerCase, firstLetterUpperCase: upperCase } = utils;
34
+ const { firstLetterLowerCase: lowerCase, firstLetterUpperCase: upperCase, getLocalConfig } = utils;
33
35
  const templatePath = path.join(__dirname, 'template.ejs');
34
36
 
35
37
  /**
@@ -42,9 +44,10 @@ const templatePath = path.join(__dirname, 'template.ejs');
42
44
  * @returns {Object[]} - data of multiple dynamoDb template
43
45
  */
44
46
 
45
- function createDataForDefaultSnsInSqs(flowSchema, srcPath) {
47
+ function createDataForDefaultSnsInSqs(_izContext, flowSchema, srcPath) {
46
48
  let resultsForCreateDefaultSnsInSqs = [];
47
49
  let flowTag = upperCase(flowSchema.flowTag)
50
+ let serviceTag = getLocalConfig("iz_serviceTag")
48
51
  // console.log("create topic by flowSteps", flowSteps)
49
52
  const setting = {
50
53
  initialData: "Resources:\n",
@@ -56,7 +59,8 @@ function createDataForDefaultSnsInSqs(flowSchema, srcPath) {
56
59
 
57
60
  let generateTriggerCacheQueueNames = [
58
61
  {
59
- queueName: "ProcessTriggerCache" + upperCase(flowTag) + upperCase(HANDLER.hdrSqs)
62
+ // queueName: "ProcessTriggerCache" + upperCase(flowTag) + upperCase(HANDLER.hdrSqs)
63
+ queueName: `${createFlowTypeConcat(_izContext, { serviceTag: serviceTag, flowTag: upperCase(flowTag) })}_Main`
60
64
  },
61
65
  {
62
66
  queueName: "CheckTriggerCache" + upperCase(flowTag) + "Complete" + upperCase(HANDLER.hdrSqs)
@@ -1,22 +1,22 @@
1
1
  #------- queue ---------
2
- <%- queueName %>:
2
+ <%- resourceNameFromQueueName(queueName) %>:
3
3
  Type: "AWS::SQS::Queue"
4
4
  Properties:
5
5
  QueueName: ${self:custom.iz_resourcePrefix}<%- queueName %>
6
6
  RedrivePolicy:
7
7
  deadLetterTargetArn: #!GetAtt
8
8
  Fn::GetAtt:
9
- - <%- queueName %>DLQ
9
+ - <%- resourceNameFromQueueName(queueName) %>DLQ
10
10
  - Arn
11
11
  maxReceiveCount: 3
12
12
  VisibilityTimeout: 120
13
13
 
14
- <%- queueName %>DLQ:
14
+ <%- resourceNameFromQueueName(queueName) %>DLQ:
15
15
  Type: AWS::SQS::Queue
16
16
  Properties:
17
17
  QueueName: ${self:custom.iz_resourcePrefix}<%- queueName %>DLQ
18
18
 
19
- <%- queueName %>Policy:
19
+ <%- resourceNameFromQueueName(queueName) %>Policy:
20
20
  Type: AWS::SQS::QueuePolicy
21
21
  Properties:
22
22
  PolicyDocument:
@@ -27,14 +27,20 @@
27
27
  Principal: "*"
28
28
  Resource: #!GetAtt
29
29
  Fn::GetAtt:
30
- - <%- queueName %>
30
+ - <%- resourceNameFromQueueName(queueName) %>
31
31
  - Arn
32
32
  Action: "SQS:SendMessage"
33
33
  Queues:
34
- - Ref: <%- queueName %>
34
+ - Ref: <%- resourceNameFromQueueName(queueName) %>
35
35
  #<#<%- firstLetterUpperCase(queueName) %>QueueSetting#>
36
36
  #<#/<%- firstLetterUpperCase(queueName) %>QueueSetting#>
37
37
 
38
+ <% function resourceNameFromQueueName(queueName) {
39
+ if (queueName.includes("_")) {
40
+ queueName = queueName.split("_").join("")
41
+ }
42
+ return queueName
43
+ } %>
38
44
  <%_ function firstLetterUpperCase(text){
39
45
  return text.charAt(0).toUpperCase() + text.slice(1)
40
46
  } _%>
@@ -145,6 +145,9 @@ export default async function createObjectComplete (
145
145
  errorsFound: errorsFound
146
146
  }
147
147
 
148
+ //(<beforeSendMessage>)
149
+ //(</beforeSendMessage>)
150
+
148
151
  messageObject = callingFlowSharedLib.addParentPassBackPropertiesToSnsResponseMessageObject(passBackProperties, messageObject)
149
152
  let messageAttributes = callingFlowSharedLib.addParentPassBackCallingFlowToSnsResponseMessageAttributes(passBackProperties, {})
150
153
 
@@ -118,7 +118,7 @@ function createParamForCreateSource(handlerType, srcPath) {
118
118
  resourceLocation: SOURCE_PATH.resourceLocationRelationshipPerAction,
119
119
  functionNameConfig: upperCase(SHORT_FUNCTION_NAME(FUNCTION_NAME.changeRel)) + upperCase(shortNameHandler(handlerType)),
120
120
  roleName: SOURCE_GENERATE_IAM_ROLE.RelationshipRole,
121
- serviceTag: getLocalConfig(path.join(srcPath, "../"), "iz_serviceTag"),
121
+ serviceTag: getLocalConfig("iz_serviceTag"),
122
122
  apiTemplate,
123
123
  dsqTemplate,
124
124
  invTemplate,
@@ -143,7 +143,7 @@ function createParamForCreateSource(allObjectRelationships, handlerType, srcPath
143
143
  resourceLocation: SOURCE_PATH.resourceLocationRelationshipPerAction,
144
144
  functionNameConfig: upperCase(SHORT_FUNCTION_NAME(FUNCTION_NAME.createRel)) + upperCase(shortNameHandler(handlerType)),
145
145
  roleName: SOURCE_GENERATE_IAM_ROLE.RelationshipRole,
146
- serviceTag: getLocalConfig(path.join(srcPath, "../"), "iz_serviceTag"),
146
+ serviceTag: getLocalConfig("iz_serviceTag"),
147
147
  apiTemplate,
148
148
  dsqTemplate,
149
149
  invTemplate,
@@ -144,7 +144,7 @@ function createParamForCreateSource(allObjectRelationships, handlerType, srcPath
144
144
  resourceLocation: SOURCE_PATH.resourceLocationRelationshipPerAction,
145
145
  functionNameConfig: upperCase(SHORT_FUNCTION_NAME(FUNCTION_NAME.deleteRel)) + upperCase(shortNameHandler(handlerType)),
146
146
  roleName: SOURCE_GENERATE_IAM_ROLE.RelationshipRole,
147
- serviceTag: getLocalConfig(path.join(srcPath, "../"), "iz_serviceTag"),
147
+ serviceTag: getLocalConfig("iz_serviceTag"),
148
148
  apiTemplate,
149
149
  dsqTemplate,
150
150
  invTemplate,
@@ -145,7 +145,7 @@ function createParamForCreateSource(allObjectRelationships, handlerType, srcPath
145
145
  resourceLocation: SOURCE_PATH.resourceLocationRelationshipPerAction,
146
146
  functionNameConfig: upperCase(SHORT_FUNCTION_NAME(FUNCTION_NAME.getRel)) + upperCase(shortNameHandler(handlerType)),
147
147
  roleName: SOURCE_GENERATE_IAM_ROLE.RelationshipRole,
148
- serviceTag: getLocalConfig(path.join(srcPath, "../"), "iz_serviceTag"),
148
+ serviceTag: getLocalConfig("iz_serviceTag"),
149
149
  apiTemplate,
150
150
  dsqTemplate,
151
151
  invTemplate,
@@ -121,7 +121,7 @@ function createParamForCreateSource(allObjectRelationships, handlerType, srcPath
121
121
  resourceLocation: SOURCE_PATH.resourceLocationRelationshipPerAction,
122
122
  functionNameConfig: upperCase(SHORT_FUNCTION_NAME(FUNCTION_NAME.moveRel)) + upperCase(shortNameHandler(handlerType)),
123
123
  roleName: SOURCE_GENERATE_IAM_ROLE.RelationshipRole,
124
- serviceTag: getLocalConfig(path.join(srcPath, "../"), "iz_serviceTag"),
124
+ serviceTag: getLocalConfig("iz_serviceTag"),
125
125
  apiTemplate,
126
126
  dsqTemplate,
127
127
  invTemplate,
@@ -138,7 +138,7 @@ function createParamForCreateSource(allObjectRelationships, handlerType, srcPath
138
138
  resourceLocation: SOURCE_PATH.resourceLocationRelationshipPerAction,
139
139
  functionNameConfig: upperCase(SHORT_FUNCTION_NAME(FUNCTION_NAME.updateRel)) + upperCase(shortNameHandler(handlerType)),
140
140
  roleName: SOURCE_GENERATE_IAM_ROLE.RelationshipRole,
141
- serviceTag: getLocalConfig(path.join(srcPath, "../"), "iz_serviceTag"),
141
+ serviceTag: getLocalConfig("iz_serviceTag"),
142
142
  apiTemplate,
143
143
  dsqTemplate,
144
144
  invTemplate,