@izara_project/izara-core-generate-service-code 1.0.22 → 1.0.24

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 (106) hide show
  1. package/package.json +1 -1
  2. package/src/generateCode/generateFlowSchema/GenerateCodeFlowSchema.js +11 -8
  3. package/src/generateCode/generateFlowSchema/event/eventBridgeComponent/functionYaml/data.js +2 -2
  4. package/src/generateCode/generateFlowSchema/event/eventBridgeComponent/functionYaml/template.ejs +3 -10
  5. package/src/generateCode/generateFlowSchema/event/eventBridgeComponent/handler/inv/data.js +5 -4
  6. package/src/generateCode/generateFlowSchema/event/eventBridgeComponent/handler/inv/template.ejs +5 -14
  7. package/src/generateCode/generateFlowSchema/event/eventBridgeComponent/index.js +4 -13
  8. package/src/generateCode/generateFlowSchema/event/eventBridgeComponent/mainFunction/data.js +2 -2
  9. package/src/generateCode/generateFlowSchema/event/extTopicComponent/index.js +5 -9
  10. package/src/generateCode/generateFlowSchema/event/extTopicComponent/process/functionYaml/data.js +6 -10
  11. package/src/generateCode/generateFlowSchema/event/extTopicComponent/process/functionYaml/template.ejs +4 -11
  12. package/src/generateCode/generateFlowSchema/event/extTopicComponent/process/handler/data.js +2 -2
  13. package/src/generateCode/generateFlowSchema/event/extTopicComponent/sns-in-sqs/data.js +2 -2
  14. package/src/generateCode/generateFlowSchema/event/extTopicComponent/sns-out/data.js +4 -3
  15. package/src/generateCode/generateFlowSchema/event/lambdaSyncApiComponent/functionYaml/data.js +4 -8
  16. package/src/generateCode/generateFlowSchema/event/lambdaSyncApiComponent/functionYaml/template.ejs +12 -21
  17. package/src/generateCode/generateFlowSchema/event/lambdaSyncApiComponent/handler/data.js +2 -2
  18. package/src/generateCode/generateFlowSchema/event/lambdaSyncApiComponent/index.js +3 -7
  19. package/src/generateCode/generateFlowSchema/event/lambdaSyncInvComponent/functionYaml/data.js +11 -9
  20. package/src/generateCode/generateFlowSchema/event/lambdaSyncInvComponent/functionYaml/template.ejs +3 -10
  21. package/src/generateCode/generateFlowSchema/event/lambdaSyncInvComponent/handler/data.js +2 -2
  22. package/src/generateCode/generateFlowSchema/event/lambdaSyncInvComponent/index.js +3 -7
  23. package/src/generateCode/generateFlowSchema/event/ownTopicComponent/endpointComponent/functionYaml/data.js +4 -3
  24. package/src/generateCode/generateFlowSchema/event/ownTopicComponent/endpointComponent/handler/data.js +3 -3
  25. package/src/generateCode/generateFlowSchema/event/ownTopicComponent/flowSchemaComponent/functionYaml/data.js +8 -11
  26. package/src/generateCode/generateFlowSchema/event/ownTopicComponent/flowSchemaComponent/handler/data.js +2 -2
  27. package/src/generateCode/generateFlowSchema/event/ownTopicComponent/flowSchemaComponent/mainFunction/data.js +2 -2
  28. package/src/generateCode/generateFlowSchema/event/ownTopicComponent/index.js +8 -24
  29. package/src/generateCode/generateFlowSchema/event/ownTopicComponent/sns-in/data.js +2 -2
  30. package/src/generateCode/generateFlowSchema/event/ownTopicComponent/sns-out/data.js +4 -3
  31. package/src/generateCode/generateFlowSchema/event/s3Component/flowSchemaMainFunction/data.js +14 -12
  32. package/src/generateCode/generateFlowSchema/event/s3Component/flowSchemaMainFunction/template.ejs +5 -8
  33. package/src/generateCode/generateFlowSchema/event/s3Component/flowSchemaMainFunction/templateByStatusType/statusFieldTemplate.ejs +30 -0
  34. package/src/generateCode/generateFlowSchema/event/s3Component/flowSchemaMainFunction/templateByStatusType/storedCacheTemplate.ejs +26 -0
  35. package/src/generateCode/generateFlowSchema/event/s3Component/flowSchemaMainFunction/templateByStatusType/triggerCacheTemplate.ejs +44 -0
  36. package/src/generateCode/generateFlowSchema/event/s3Component/index.js +23 -55
  37. package/src/generateCode/generateFlowSchema/event/s3Component/upload/confirmReserved/functionYaml/data.js +3 -7
  38. package/src/generateCode/generateFlowSchema/event/s3Component/upload/confirmReserved/handler/data.js +3 -7
  39. package/src/generateCode/generateFlowSchema/event/s3Component/upload/confirmReserved/mainFunction/data.js +3 -7
  40. package/src/generateCode/generateFlowSchema/event/s3Component/upload/confirmReserved/queue/data.js +2 -2
  41. package/src/generateCode/generateFlowSchema/event/s3Component/upload/createObject/functionYaml/data.js +3 -7
  42. package/src/generateCode/generateFlowSchema/event/s3Component/upload/createObject/handler/data.js +3 -7
  43. package/src/generateCode/generateFlowSchema/event/s3Component/upload/createObject/mainFunction/data.js +3 -7
  44. package/src/generateCode/generateFlowSchema/event/s3Component/upload/preSignUrl/createPreSignUrl/functionYaml/data.js +3 -7
  45. package/src/generateCode/generateFlowSchema/event/s3Component/upload/preSignUrl/createPreSignUrl/handler/data.js +3 -7
  46. package/src/generateCode/generateFlowSchema/event/s3Component/upload/preSignUrl/createPreSignUrl/mainFunction/data.js +3 -7
  47. package/src/generateCode/generateFlowSchema/event/s3Component/upload/preSignUrl/createPreSignUrl/queue/data.js +2 -2
  48. package/src/generateCode/generateFlowSchema/event/s3Component/upload/preSignUrl/reservedLimit/functionYaml/data.js +6 -10
  49. package/src/generateCode/generateFlowSchema/event/s3Component/upload/preSignUrl/reservedLimit/handler/data.js +3 -7
  50. package/src/generateCode/generateFlowSchema/event/s3Component/upload/preSignUrl/reservedLimit/mainFunction/data.js +3 -7
  51. package/src/generateCode/generateFlowSchema/event/s3Component/upload/preSignUrl/reservedLimit/sqs/data.js +2 -2
  52. package/src/generateCode/generateFlowSchema/event/s3Component/upload/processFile/functionYml/HdrS3/data.js +3 -7
  53. package/src/generateCode/generateFlowSchema/event/s3Component/upload/processFile/handler/handlerS3/data.js +3 -7
  54. package/src/generateCode/generateFlowSchema/event/s3Component/upload/processFile/mainFunction/data.js +3 -7
  55. package/src/generateCode/generateFlowSchema/event/s3Component/upload/relate/S3/data.js +4 -4
  56. package/src/generateCode/generateFlowSchema/event/s3Component/upload/relate/sns-out/data.js +5 -3
  57. package/src/generateCode/generateFlowSchema/event/s3Component/websocket/dynamoDb/ReservedTableData.js +3 -3
  58. package/src/generateCode/generateFlowSchema/flowSchemaMainFunction/data.js +4 -8
  59. package/src/generateCode/generateFlowSchema/flowSchemaMainFunction/template.ejs +3 -5
  60. package/src/generateCode/generateFlowSchema/flowStep/flowStep.js +7 -2
  61. package/src/generateCode/generateFlowSchema/libs/data.js +3 -7
  62. package/src/generateCode/generateFlowSchema/statusType/statusFieldComponent/functionYaml/data.js +9 -9
  63. package/src/generateCode/generateFlowSchema/statusType/statusFieldComponent/handler/data.js +1 -5
  64. package/src/generateCode/generateFlowSchema/statusType/statusFieldComponent/index.js +6 -18
  65. package/src/generateCode/generateFlowSchema/statusType/statusFieldComponent/mainFunction/data.js +15 -14
  66. package/src/generateCode/generateFlowSchema/statusType/triggerCacheComponent/checkTriggerCacheComplete/functionYaml/data.js +4 -8
  67. package/src/generateCode/generateFlowSchema/statusType/triggerCacheComponent/checkTriggerCacheComplete/handler/data.js +15 -15
  68. package/src/generateCode/generateFlowSchema/statusType/triggerCacheComponent/checkTriggerCacheComplete/mainFunction/data.js +15 -15
  69. package/src/generateCode/generateFlowSchema/statusType/triggerCacheComponent/index.js +13 -33
  70. package/src/generateCode/generateFlowSchema/statusType/triggerCacheComponent/processTriggerCache/functionYaml/data.js +4 -8
  71. package/src/generateCode/generateFlowSchema/statusType/triggerCacheComponent/processTriggerCache/handler/data.js +12 -14
  72. package/src/generateCode/generateFlowSchema/statusType/triggerCacheComponent/processTriggerCache/mainFunction/data.js +11 -14
  73. package/src/generateCode/generateFlowSchema/statusType/triggerCacheComponent/triggerCacheComplete/functionYaml/dsq/data.js +4 -9
  74. package/src/generateCode/generateFlowSchema/statusType/triggerCacheComponent/triggerCacheComplete/functionYaml/sqs/data.js +4 -9
  75. package/src/generateCode/generateFlowSchema/statusType/triggerCacheComponent/triggerCacheComplete/handler/dsq/data.js +11 -14
  76. package/src/generateCode/generateFlowSchema/statusType/triggerCacheComponent/triggerCacheComplete/handler/sqs/data.js +11 -14
  77. package/src/generateCode/generateFlowSchema/statusType/triggerCacheComponent/triggerCacheComplete/mainFunction/data.js +15 -15
  78. package/src/generateCode/generateFlowSchema/statusType/triggerCacheComponent/triggerCacheQueue/data.js +2 -3
  79. package/src/generateCode/generateSchema/actionEndpointCompleteComponent/create/mainFunction/template.ejs +185 -103
  80. package/src/generateCode/generateSchema/actionEndpointCompleteComponent/create/sns-out/data.js +2 -1
  81. package/src/generateCode/generateSchema/actionEndpointCompleteComponent/delete/sns-out/data.js +2 -1
  82. package/src/generateCode/generateSchema/actionEndpointCompleteComponent/get/sns-out/data.js +2 -1
  83. package/src/generateCode/generateSchema/actionEndpointCompleteComponent/update/mainFunction/template.ejs +137 -71
  84. package/src/generateCode/generateSchema/actionEndpointCompleteComponent/update/sns-out/data.js +2 -1
  85. package/src/generateCode/generateSchema/actionEndpointComponent/mainFunction/create/main/template.ejs +1 -1
  86. package/src/generateCode/generateSchema/actionEndpointComponent/yaml/data.js +6 -4
  87. package/src/generateCode/generateSchema/findDataComponent/mainFunction/data.js +1 -1
  88. package/src/generateCode/generateSchema/relationshipPerActionComponent/changeRelationship/complete/sns-out/data.js +2 -1
  89. package/src/generateCode/generateSchema/relationshipPerActionComponent/create/action/functionYaml/data.js +1 -0
  90. package/src/generateCode/generateSchema/relationshipPerActionComponent/create/complete/sns-out/data.js +2 -1
  91. package/src/generateCode/generateSchema/relationshipPerActionComponent/delete/action/functionYaml/data.js +1 -0
  92. package/src/generateCode/generateSchema/relationshipPerActionComponent/delete/complete/sns-out/data.js +2 -1
  93. package/src/generateCode/generateSchema/relationshipPerActionComponent/get/action/functionYaml/data.js +1 -0
  94. package/src/generateCode/generateSchema/relationshipPerActionComponent/get/complete/sns-out/data.js +2 -1
  95. package/src/generateCode/generateSchema/relationshipPerActionComponent/moveRelationship/complete/sns-out/data.js +2 -1
  96. package/src/generateCode/generateSchema/relationshipPerActionComponent/update/action/functionYaml/data.js +1 -0
  97. package/src/generateCode/generateSchema/relationshipPerActionComponent/update/action/sns-out/data.js +2 -1
  98. package/src/generateCode/generateSchema/relationshipPerActionComponent/update/complete/sns-out/data.js +2 -1
  99. package/src/generateCode/resourceYamlComponent/sns-out/data.js +2 -1
  100. package/src/generateCode/resourceYamlComponent/sns-out/defaultSnsOutForFindDataAndProcessLogical.js +2 -1
  101. package/src/generateCode/resourceYamlComponent/sns-out/template.ejs +2 -6
  102. package/src/generateCode.js +9 -7
  103. package/src/libs/Consts.js +9 -12
  104. package/src/libs/Utils.js +26 -1
  105. package/src/__TemplateData/flowSchema/event/externalTopic/Process/handler/data.js +0 -64
  106. package/src/__TemplateData/flowSchema/event/externalTopic/sns-out/data.js +0 -75
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@izara_project/izara-core-generate-service-code",
3
- "version": "1.0.22",
3
+ "version": "1.0.24",
4
4
  "description": "Code for locally generating per service files",
5
5
  "author": "Sven Mason <thebarbariansven@gmail.com>",
6
6
  "license": "AGPL-3.0-or-later",
@@ -85,17 +85,20 @@ async function generateTemplateDataFromFlowSchema(
85
85
 
86
86
  // ── per-flowSchema resources ─────────────────────────────────────────
87
87
  const perFlowParams = [
88
- ...createWebSocketGenerateCodeLibs(_izContext, flowSchema, appPath),
89
- ...(!flowSchema.event.includes('s3')
90
- ? await createFlowSchemaEndpointMainFunction(
91
- _izContext,
92
- flowSchema,
93
- appPath
94
- )
95
- : []),
88
+ createWebSocketGenerateCodeLibs(_izContext, flowSchema, appPath),
96
89
  ...buildFlowStepResources(_izContext, flowSchema, appPath)
97
90
  ];
98
91
 
92
+ if (!flowSchema.event.includes('s3')) {
93
+ perFlowParams.push(
94
+ await createFlowSchemaEndpointMainFunction(
95
+ _izContext,
96
+ flowSchema,
97
+ appPath
98
+ )
99
+ );
100
+ }
101
+
99
102
  // ── event handlers ───────────────────────────────────────────────────
100
103
  const eventPromises = events
101
104
  .filter(event => {
@@ -45,7 +45,7 @@ const templatePath = path.join(__dirname, 'template.ejs');
45
45
  * @param {Object} objectSchema
46
46
  * @return {{templatePath, templateData,setting}}
47
47
  */
48
- function createSourceParams(_izContext, flowSchema, srcPath) {
48
+ function createSourceParams(_izContext, flowSchema, appPath) {
49
49
  const functionName = upperCase(FUNCTION_NAME.flowSchemaEventBridge);
50
50
  // const action = SOURCE_GENERATE_IAM_ROLE.EventBridge;
51
51
  const functionNameConfig = upperCase(SOURCE_GENERATE_IAM_ROLE.EventBridge);
@@ -153,7 +153,7 @@ function createSourceParams(_izContext, flowSchema, srcPath) {
153
153
  schedules
154
154
  },
155
155
  setting: {
156
- savePath: path.join(srcPath, SOURCE_PATH.appYaml),
156
+ savePath: path.join(appPath, SOURCE_PATH.appYaml),
157
157
  saveFileName: SAVE_FILE_NAME.flowSchemaYaml,
158
158
  fileExtension: '.yml',
159
159
  isAppend: true
@@ -1,7 +1,6 @@
1
- <%_ const join = require('path').join; _%>
2
- <%- firstLetterUpperCase(functionNameConfig) %>:
3
- handler: <%- join(resourceLocation, `${functionName}_${firstLetterUpperCase(handlerType)}.main`)%>
4
- name: ${self:custom.iz_resourcePrefix}<%- firstLetterUpperCase(functionNameConfig) %>
1
+ <%- functionNameConfig %>:
2
+ handler: <%- `${resourceLocation}${functionName}_${handlerType}.main` %>
3
+ name: ${self:custom.iz_resourcePrefix}<%- functionNameConfig %>
5
4
  role: <%- roleName %>Role
6
5
  #<#<%- functionName %>FunctionSetting#>
7
6
  #<#/<%- functionName %>FunctionSetting#>
@@ -13,9 +12,3 @@
13
12
  rate: <%- schedule.rate %>
14
13
  input: <%- JSON.stringify(schedule.input) %>
15
14
  <%_ }) _%>
16
- <%_ function firstLetterUpperCase(text){
17
- return text.charAt(0).toUpperCase() + text.slice(1)
18
- } _%>
19
- <%_ function firstLetterLowerCase(str) {
20
- return str.charAt(0).toLowerCase() + str.slice(1)
21
- } _%>
@@ -33,10 +33,10 @@ const templatePath = path.join(__dirname, 'template.ejs');
33
33
  *
34
34
  * @param {Object} _izContext
35
35
  * @param {Object} flowSchema
36
- * @param {String} srcPath
36
+ * @param {String} appPath
37
37
  * @return {Object[]}
38
38
  */
39
- function data(_izContext, flowSchema, srcPath) {
39
+ function data(_izContext, flowSchema, appPath) {
40
40
  const handler = HANDLER.hdrInv;
41
41
  const flowTag = flowSchema.flowTag;
42
42
  // const action = SOURCE_GENERATE_IAM_ROLE.EventBridge;
@@ -46,7 +46,8 @@ function data(_izContext, flowSchema, srcPath) {
46
46
  templatePath: templatePath,
47
47
  templateData: {
48
48
  functionName: functionName,
49
- flowTag: flowTag,
49
+ flowTag: upperCase(flowTag),
50
+ // flowTag: ,
50
51
  // action: action,
51
52
  handler
52
53
  // roleName: SOURCE_GENERATE_IAM_ROLE.EventBridge,
@@ -54,7 +55,7 @@ function data(_izContext, flowSchema, srcPath) {
54
55
  },
55
56
  setting: {
56
57
  savePath: path.join(
57
- srcPath,
58
+ appPath,
58
59
  SOURCE_PATH.flowSchemaEventBridge,
59
60
  flowSchema.flowTag,
60
61
  'source/'
@@ -15,12 +15,10 @@ You should have received a copy of the GNU Affero General Public License
15
15
  along with this program. If not, see <http://www.gnu.org/licenses/>.
16
16
  */
17
17
 
18
-
19
-
20
- import { middlewareHandleras middlewar } from "@izara_project/izara-middleware";
18
+ import { middlewareHandler as middleware } from "@izara_project/izara-middleware";
21
19
  import callingFlowSharedLib from '@izara_project/zara-core-library-calling-flow';
22
20
 
23
- import <%- functionName %>Main from './<%- firstLetterUpperCase(functionName)%>_Main.js'
21
+ import <%- functionName %>Main from './<%- functionName %>_Main.js'
24
22
 
25
23
  //(<globalVariable>
26
24
  //</globalVariable>)
@@ -40,21 +38,14 @@ export const main = middlewareHandler.wrap(async (event, context) => {
40
38
  //(</beforeInvoke>)
41
39
 
42
40
  // invoke LambdaFunction
43
- return await <% - functionName %> Main(
41
+ return await <%- functionName %> Main(
44
42
  event._izContext, // correlationId/logger/integrationTestDetail/uniqueRequestId
45
43
  event,
46
44
  callingFlowSharedLib.addCallingFlowToPassOnProperties(event)
47
45
  );
48
46
 
49
47
  } catch (err) {
50
- event._izContext.logger.error('Error, <%- firstLetterUpperCase(flowTag) %>: ', err);
48
+ event._izContext.logger.error('Error, <%- flowTag %>: ', err);
51
49
  throw (err);
52
50
  }
53
- });
54
-
55
- <% _ function firstLetterUpperCase(text) {
56
- return text.charAt(0).toUpperCase() + text.slice(1)
57
- } _ %>
58
- <% _ function firstLetterLowerCase(str) {
59
- return str.charAt(0).toLowerCase() + str.slice(1)
60
- } _ %>
51
+ });
@@ -2,22 +2,13 @@ import createFlowSchemaEventBridgeFunctionYaml from './functionYaml/data.js';
2
2
  import createFlowSchemaEventBridgeHandler from './handler/inv/data.js';
3
3
  import createFlowSchemaEventBridgeMainFunction from './mainFunction/data.js';
4
4
 
5
- function createEventBridgeComponent(_izContext, flowSchema, rootServicePath) {
5
+ function createEventBridgeComponent(_izContext, flowSchema, appPath) {
6
6
  const component = [
7
- createFlowSchemaEventBridgeHandler(_izContext, flowSchema, saveFilePath),
8
- createFlowSchemaEventBridgeMainFunction(
9
- _izContext,
10
- flowSchema,
11
- saveFilePath
12
- ),
13
- createFlowSchemaEventBridgeFunctionYaml(
14
- _izContext,
15
- flowSchema,
16
- saveFilePath
17
- )
7
+ createFlowSchemaEventBridgeHandler(_izContext, flowSchema, appPath),
8
+ createFlowSchemaEventBridgeMainFunction(_izContext, flowSchema, appPath),
9
+ createFlowSchemaEventBridgeFunctionYaml(_izContext, flowSchema, appPath)
18
10
  ];
19
11
 
20
- console.info('generateEventBridgeComponent ✅');
21
12
  return component;
22
13
  }
23
14
 
@@ -35,7 +35,7 @@ const templatePath = path.join(__dirname, 'template.ejs');
35
35
  * @param {Object} flowSchema
36
36
  * @return {{ templatePath, templateData, setting } }
37
37
  */
38
- function data(_izContext, flowSchema, srcPath) {
38
+ function data(_izContext, flowSchema, appPath) {
39
39
  // const handler = HANDLER.hdrInv;
40
40
  const flowTag = flowSchema.flowTag;
41
41
  // const functionName = "EventBridge" + upperCase(handler);
@@ -52,7 +52,7 @@ function data(_izContext, flowSchema, srcPath) {
52
52
  },
53
53
  setting: {
54
54
  savePath: path.join(
55
- srcPath,
55
+ appPath,
56
56
  SOURCE_PATH.flowSchemaEventBridge,
57
57
  flowSchema.flowTag,
58
58
  'source/'
@@ -3,16 +3,12 @@ import createExternalSqsHandler from './process/handler/data.js';
3
3
  import createExternalTopicSnsInSqs from './sns-in-sqs/data.js';
4
4
  import createExternalTopicSnsOut from './sns-out/data.js';
5
5
 
6
- async function createExternalTopicComponent(
7
- _izContext,
8
- flowSchema,
9
- saveFilePath
10
- ) {
6
+ async function createExternalTopicComponent(_izContext, flowSchema, appPath) {
11
7
  const component = [
12
- createExternalSqsFunctionYaml(_izContext, flowSchema, saveFilePath),
13
- createExternalSqsHandler(_izContext, flowSchema, saveFilePath),
14
- ...createExternalTopicSnsInSqs(_izContext, flowSchema, saveFilePath),
15
- ...createExternalTopicSnsOut(_izContext, flowSchema, saveFilePath)
8
+ await createExternalSqsFunctionYaml(_izContext, flowSchema, appPath),
9
+ createExternalSqsHandler(_izContext, flowSchema, appPath),
10
+ ...createExternalTopicSnsInSqs(_izContext, flowSchema, appPath),
11
+ ...createExternalTopicSnsOut(_izContext, flowSchema, appPath)
16
12
  ];
17
13
 
18
14
  return component;
@@ -38,7 +38,7 @@ const {
38
38
  LAMBDA_RESOURCE
39
39
  } = consts;
40
40
 
41
- const { firstLetterUpperCase: upperCase } = utils;
41
+ const { firstLetterUpperCase: upperCase, savePath } = utils;
42
42
 
43
43
  const {
44
44
  shortNameHandler,
@@ -53,10 +53,10 @@ const templatePath = path.join(__dirname, 'template.ejs');
53
53
  * Creates source parameters for function YAML generation
54
54
  * @param {Object} _izContext - The Izara context object
55
55
  * @param {Object} flowSchema - The flow schema configuration
56
- * @param {string} srcPath - The source path for the project
56
+ * @param {string} appPath - The source path for the project
57
57
  * @returns {Promise<Array>} Array containing template configuration object
58
58
  */
59
- async function createSourceParams(_izContext, flowSchema, srcPath) {
59
+ async function createSourceParams(_izContext, flowSchema, appPath) {
60
60
  let functionName = 'Process' + upperCase(flowSchema.flowTag);
61
61
  let handlerType = upperCase(HANDLER.hdrSqs);
62
62
  let additionalResourcePermission = defaultIamRolePerAction();
@@ -92,7 +92,7 @@ async function createSourceParams(_izContext, flowSchema, srcPath) {
92
92
  .getLocalObjectSchemas(
93
93
  _izContext,
94
94
  [flowSchema.objType.objectType],
95
- path.join(srcPath, './schemas')
95
+ path.join(appPath, 'src/schemas')
96
96
  )
97
97
  .then(res => res.records[0]);
98
98
  if (!objectSchema) {
@@ -132,11 +132,7 @@ async function createSourceParams(_izContext, flowSchema, srcPath) {
132
132
  return {
133
133
  templatePath: templatePath,
134
134
  templateData: {
135
- resourceLocation: path.join(
136
- SOURCE_PATH.resourceLocationFlowSchema,
137
- upperCase(flowSchema.flowTag),
138
- 'source/'
139
- ),
135
+ resourceLocation: savePath.flowSchemaFlowTag(flowSchema.flowTag),
140
136
  functionName,
141
137
  handlerType,
142
138
  additionalResourcePermission,
@@ -147,7 +143,7 @@ async function createSourceParams(_izContext, flowSchema, srcPath) {
147
143
  queueName
148
144
  },
149
145
  setting: {
150
- savePath: path.join(srcPath, SOURCE_PATH.appYaml),
146
+ savePath: path.join(appPath, SOURCE_PATH.appYaml),
151
147
  saveFileName: SAVE_FILE_NAME.flowSchemaYaml,
152
148
  fileExtension: '.yml',
153
149
  isAppend: true
@@ -1,7 +1,6 @@
1
- <%_ const join = require('path').join; _%>
2
- <%- firstLetterUpperCase(functionNameConfig) %>:
3
- handler: <%- join(resourceLocation, `${firstLetterUpperCase(functionName)}_${firstLetterUpperCase(handlerType)}.main`)%>
4
- name: ${self:custom.iz_resourcePrefix}<%- firstLetterUpperCase(functionName) %><%- firstLetterUpperCase(handlerType) %>
1
+ <%- functionNameConfig %>:
2
+ handler: <%- `${resourceLocation}${functionName}_${handlerType}.main`%>
3
+ name: ${self:custom.iz_resourcePrefix}<%- functionName %><%- handlerType %>
5
4
  role: <%- roleName %>Role
6
5
  #<#<%- functionName %><%- handlerType %>FunctionSetting#>
7
6
  #<#/<%- functionName %><%- handlerType %>FunctionSetting#>
@@ -11,10 +10,4 @@
11
10
  batchSize: 10
12
11
  filterPatterns: #**** need to update serverless framework upper v.2.69.1
13
12
  - 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
- } _%>
18
- <%_ function firstLetterLowerCase(str) {
19
- return str.charAt(0).toLowerCase() + str.slice(1)
20
- } _%>
13
+ - body: {"MessageAttributes":{"callingFlow":{"Value":[{"exists":false}]}}}
@@ -35,7 +35,7 @@ const templatePath = path.join(__dirname, 'template.ejs');
35
35
  * @return {{templatePath, templateData,setting}}
36
36
  */
37
37
 
38
- function createSourceParams(_izContext, flowSchema, srcPath) {
38
+ function createSourceParams(_izContext, flowSchema, appPath) {
39
39
  let functionName = 'Process' + upperCase(flowSchema.flowTag);
40
40
  let handlerType = upperCase(HANDLER.hdrSqs);
41
41
  let queueName = 'Process' + upperCase(flowSchema.flowTag) + handlerType;
@@ -49,7 +49,7 @@ function createSourceParams(_izContext, flowSchema, srcPath) {
49
49
  },
50
50
  setting: {
51
51
  savePath: path.join(
52
- srcPath,
52
+ appPath,
53
53
  SOURCE_PATH.flowSchema,
54
54
  upperCase(flowSchema.flowTag),
55
55
  'MainHandler/',
@@ -37,12 +37,12 @@ const templatePath = path.join(__dirname, 'template.ejs');
37
37
  * @returns {Object[]} - data of multiple dynamoDb template
38
38
  */
39
39
 
40
- function createDataForDefaultSnsInSqs(_izContext, flowSchema, srcPath) {
40
+ function createDataForDefaultSnsInSqs(_izContext, flowSchema, appPath) {
41
41
  let resultsForCreateDefaultSnsInSqs = [];
42
42
  let flowSteps = Object.keys(flowSchema.flowSteps);
43
43
  const setting = {
44
44
  initialData: 'Resources:\n',
45
- savePath: path.join(srcPath, SOURCE_PATH.resourceYaml),
45
+ savePath: path.join(appPath, SOURCE_PATH.resourceYaml),
46
46
  saveFileName: SAVE_FILE_NAME.snsInSqsYaml,
47
47
  fileExtension: '.yml',
48
48
  isAppend: true
@@ -41,15 +41,16 @@ const templatePath = path.join(
41
41
  * @returns {Object[]} - data of multiple dynamoDb template
42
42
  */
43
43
 
44
- function createDataForDefaultSnsInSqs(_izContext, flowSchema, srcPath) {
44
+ function createDataForDefaultSnsInSqs(_izContext, flowSchema, appPath) {
45
45
  let resultsForCreateDefaultSnsInSqs = [];
46
46
  let flowSteps = Object.keys(flowSchema.flowSteps);
47
47
  const setting = {
48
48
  initialData: 'Resources:\n',
49
- savePath: path.join(srcPath, SOURCE_PATH.resourceYaml),
49
+ savePath: path.join(appPath, SOURCE_PATH.resourceYaml),
50
50
  saveFileName: SAVE_FILE_NAME.snsOutYaml,
51
51
  fileExtension: '.yml',
52
- isAppend: true
52
+ isAppend: true,
53
+ fromFile: 'external/sns-out/data.js'
53
54
  };
54
55
 
55
56
  let topicOut = `${upperCase(flowSchema.flowTag)}`;
@@ -41,12 +41,12 @@ const templatePath = path.join(__dirname, 'template.ejs');
41
41
  * @param {Object} objectSchema
42
42
  * @return {{templatePath, templateData,setting}}
43
43
  */
44
- function createSourceParamsApi(_izContext, flowSchema, srcPath) {
44
+ function createSourceParamsApi(_izContext, flowSchema, appPath) {
45
45
  let functionName = 'Process' + upperCase(flowSchema.flowTag);
46
46
  let handlerType = upperCase(HANDLER.hdrApi);
47
47
  let additionalResourcePermission = defaultIamRolePerAction();
48
48
 
49
- const configPath = path.join(srcPath, '../../config/serverless.config.yml');
49
+ const configPath = path.join(appPath, '../config/serverless.config.yml');
50
50
  const serverlessConfig = fs.readFileSync(configPath, 'utf8');
51
51
  const config = yaml.parse(serverlessConfig);
52
52
  const serviceTag = config.main_config.iz_serviceTag;
@@ -54,11 +54,7 @@ function createSourceParamsApi(_izContext, flowSchema, srcPath) {
54
54
  return {
55
55
  templatePath: templatePath,
56
56
  templateData: {
57
- resourceLocation: path.join(
58
- SOURCE_PATH.resourceLocationFlowSchema,
59
- upperCase(flowSchema.flowTag),
60
- 'source/'
61
- ),
57
+ resourceYamlFlowSchemaFlowTag,
62
58
  functionName,
63
59
  handlerType,
64
60
  additionalResourcePermission,
@@ -69,7 +65,7 @@ function createSourceParamsApi(_izContext, flowSchema, srcPath) {
69
65
  serviceTag: serviceTag
70
66
  },
71
67
  setting: {
72
- savePath: path.join(srcPath, SOURCE_PATH.appYaml),
68
+ savePath: path.join(appPath, SOURCE_PATH.appYaml),
73
69
  saveFileName: SAVE_FILE_NAME.flowSchemaYaml,
74
70
  fileExtension: '.yml',
75
71
  isAppend: true
@@ -1,28 +1,19 @@
1
- <%_ const join = require('path').join _%>
2
- <%- firstLetterUpperCase(functionNameConfig) %>:
3
- handler: <%- join(resourceLocation, `${firstLetterUpperCase(functionName)}_${firstLetterUpperCase(handlerType)}.main`) %>
4
- name: ${self:custom.iz_resourcePrefix}<%- firstLetterUpperCase(functionName) %><%- firstLetterUpperCase(handlerType) %>
5
- role: <%- firstLetterUpperCase(roleName) _%>Role
6
- #<#<%- firstLetterUpperCase(functionName) %><%- firstLetterUpperCase(handlerType) %>FunctionSetting#>
7
- #<#/<%- firstLetterUpperCase(functionName) %><%- firstLetterUpperCase(handlerType) %>FunctionSetting#>
1
+ <%- functionNameConfig %>:
2
+ handler: <%- `${resourceLocation}${functionName}_${handlerType}.main` %>
3
+ name: ${self:custom.iz_resourcePrefix}<%- functionName %><%- handlerType %>
4
+ role: <%- roleName %>Role
5
+ #<#<%- functionName %><%- handlerType %>FunctionSetting#>
6
+ #<#/<%- functionName %><%- handlerType %>FunctionSetting#>
8
7
  events:
9
8
  - httpApi:
10
- path: /<%- serviceTag %>/<%- firstLetterLowerCase(functionName) %>/<%- functionName %>
9
+ path: /<%- serviceTag %>/<%- functionName %>/<%- functionName %>
11
10
  method: <%- event %>
12
11
  authorizer: authorizerServiceSchema
13
- #<#<%- firstLetterUpperCase(functionName) _%><%- firstLetterUpperCase(handlerType) %>AppLevelAuthorizer#>
14
- #<#/<%- firstLetterUpperCase(functionName) _%><%- firstLetterUpperCase(handlerType) %>AppLevelAuthorizer#>
12
+ #<#<%- functionName %><%- handlerType %>AppLevelAuthorizer#>
13
+ #<#/<%- functionName %><%- handlerType %>AppLevelAuthorizer#>
15
14
  - httpApi:
16
- path: /<%- serviceTag %>/<%- firstLetterLowerCase(functionName) %>/<%- functionName %>/{targetUserId}
15
+ path: /<%- serviceTag %>/<%- functionName %>/<%- functionName %>/{targetUserId}
17
16
  method: <%- event %>
18
17
  authorizer: authorizerServiceSchema
19
- #<#<%- firstLetterUpperCase(functionName) _%><%- firstLetterUpperCase(handlerType) %>UserLevelAuthorizer#>
20
- #<#/<%- firstLetterUpperCase(functionName) _%><%- firstLetterUpperCase(handlerType) %>UserLevelAuthorizer#>
21
-
22
-
23
- <%_ function firstLetterUpperCase(text){
24
- return text.charAt(0).toUpperCase() + text.slice(1)
25
- } _%>
26
- <%_ function firstLetterLowerCase(str) {
27
- return str.charAt(0).toLowerCase() + str.slice(1)
28
- } _%>
18
+ #<#<%- functionName %><%- handlerType %>UserLevelAuthorizer#>
19
+ #<#/<%- functionName %><%- handlerType %>UserLevelAuthorizer#>
@@ -35,7 +35,7 @@ const templatePath = path.join(__dirname, 'template.ejs');
35
35
  * @param {Object} objectSchema
36
36
  * @return {{templatePath, templateData,setting}}
37
37
  */
38
- function createSourceParamsApi(_izContext, flowSchema, srcPath) {
38
+ function createSourceParamsApi(_izContext, flowSchema, appPath) {
39
39
  const functionName = 'Process' + upperCase(flowSchema.flowTag);
40
40
  const handlerType = upperCase(HANDLER.hdrApi);
41
41
 
@@ -49,7 +49,7 @@ function createSourceParamsApi(_izContext, flowSchema, srcPath) {
49
49
  },
50
50
  setting: {
51
51
  savePath: path.join(
52
- srcPath,
52
+ appPath,
53
53
  SOURCE_PATH.flowSchema,
54
54
  upperCase(flowSchema.flowTag),
55
55
  'MainHandler/',
@@ -1,14 +1,10 @@
1
1
  import createFlowSchemaLambdaSyncFunctionYamlApi from './functionYaml/data.js';
2
2
  import createFlowSchemaLambdaSyncHandlerApi from './handler/data.js';
3
3
 
4
- function createLambdaSyncApiComponent(_izContext, flowSchema, saveFilePath) {
4
+ function createLambdaSyncApiComponent(_izContext, flowSchema, appPath) {
5
5
  const component = [
6
- createFlowSchemaLambdaSyncFunctionYamlApi(
7
- _izContext,
8
- flowSchema,
9
- saveFilePath
10
- ),
11
- createFlowSchemaLambdaSyncHandlerApi(_izContext, flowSchema, saveFilePath)
6
+ createFlowSchemaLambdaSyncFunctionYamlApi(_izContext, flowSchema, appPath),
7
+ createFlowSchemaLambdaSyncHandlerApi(_izContext, flowSchema, appPath)
12
8
  ];
13
9
 
14
10
  return component;
@@ -28,7 +28,7 @@ const { HANDLER, SOURCE_PATH, SAVE_FILE_NAME } = consts;
28
28
 
29
29
  const { shortNameHandler, defaultIamRolePerAction } = libs;
30
30
 
31
- const { firstLetterUpperCase: upperCase } = utils;
31
+ const { firstLetterUpperCase: upperCase, savePath } = utils;
32
32
 
33
33
  const templatePath = path.join(__dirname, 'template.ejs');
34
34
  /**
@@ -38,7 +38,7 @@ const templatePath = path.join(__dirname, 'template.ejs');
38
38
  * @param {Object} objectSchema
39
39
  * @return {{templatePath, templateData,setting}}
40
40
  */
41
- function createSourceParamsInvoke(_izContext, flowSchema, srcPath) {
41
+ function createSourceParamsInvoke(_izContext, flowSchema, appPath) {
42
42
  const functionName = 'Process' + upperCase(flowSchema.flowTag);
43
43
  const handlerType = upperCase(HANDLER.hdrInv);
44
44
  const additionalResourcePermission = defaultIamRolePerAction();
@@ -46,12 +46,14 @@ function createSourceParamsInvoke(_izContext, flowSchema, srcPath) {
46
46
  return {
47
47
  templatePath: templatePath,
48
48
  templateData: {
49
- resourceLocation: path.join(
50
- SOURCE_PATH.resourceLocationFlowSchema,
51
- upperCase(flowSchema.flowTag),
52
- 'source/'
53
- ),
54
- functionName,
49
+ resourceLocation:
50
+ // path.join(
51
+ // SOURCE_PATH.resourceLocationFlowSchema,
52
+ // upperCase(flowSchema.flowTag),
53
+ // 'MainHandler/',
54
+ // 'source/'
55
+ // ),
56
+ savePath.flowSchemaFlowTag(flowSchema.flowTag),
55
57
  handlerType,
56
58
  additionalResourcePermission,
57
59
  functionNameConfig:
@@ -59,7 +61,7 @@ function createSourceParamsInvoke(_izContext, flowSchema, srcPath) {
59
61
  roleName: upperCase(flowSchema.flowTag)
60
62
  },
61
63
  setting: {
62
- savePath: path.join(srcPath, SOURCE_PATH.appYaml),
64
+ savePath: path.join(appPath, SOURCE_PATH.appYaml),
63
65
  saveFileName: SAVE_FILE_NAME.flowSchemaYaml,
64
66
  fileExtension: '.yml',
65
67
  isAppend: true
@@ -1,13 +1,6 @@
1
- <%_ const join = require('path').join; _%>
2
- <%- firstLetterUpperCase(functionNameConfig) %>:
3
- handler: <%- join(resourceLocation, `${firstLetterUpperCase(functionName)}_${firstLetterUpperCase(handlerType)}.main`)%>
4
- name: ${self:custom.iz_resourcePrefix}<%- firstLetterUpperCase(functionName) %><%- firstLetterUpperCase(handlerType) %>
1
+ <%- functionNameConfig %>:
2
+ handler: <%- `${resourceLocation}${functionName}_${handlerType}.main` %>
3
+ name: ${self:custom.iz_resourcePrefix}<%- functionName %><%- handlerType %>
5
4
  role: <%- roleName %>Role
6
5
  #<#<%- functionName %><%- handlerType %>FunctionSetting#>
7
6
  #<#/<%- functionName %><%- handlerType %>FunctionSetting#>
8
- <%_ function firstLetterUpperCase(text){
9
- return text.charAt(0).toUpperCase() + text.slice(1)
10
- } _%>
11
- <%_ function firstLetterLowerCase(str) {
12
- return str.charAt(0).toLowerCase() + str.slice(1)
13
- } _%>
@@ -35,7 +35,7 @@ const templatePath = path.join(__dirname, 'template.ejs');
35
35
  * @return {{templatePath, templateData,setting}}
36
36
  */
37
37
 
38
- function createSourceParamsInvoke(_izContext, flowSchema, srcPath) {
38
+ function createSourceParamsInvoke(_izContext, flowSchema, appPath) {
39
39
  const functionName = 'Process' + upperCase(flowSchema.flowTag);
40
40
  const handlerType = upperCase(HANDLER.hdrInv);
41
41
 
@@ -47,7 +47,7 @@ function createSourceParamsInvoke(_izContext, flowSchema, srcPath) {
47
47
  },
48
48
  setting: {
49
49
  savePath: path.join(
50
- srcPath,
50
+ appPath,
51
51
  SOURCE_PATH.flowSchema,
52
52
  upperCase(flowSchema.flowTag),
53
53
  'MainHandler/',
@@ -1,14 +1,10 @@
1
1
  import createFlowSchemaLambdaSyncFunctionYamlInv from './functionYaml/data.js';
2
2
  import createFlowSchemaLambdaSyncHandlerInv from './handler/data.js';
3
3
 
4
- function CreateLambdaSyncInvokeComponent(_izContext, flowSchema, saveFilePath) {
4
+ function CreateLambdaSyncInvokeComponent(_izContext, flowSchema, appPath) {
5
5
  const component = [
6
- createFlowSchemaLambdaSyncFunctionYamlInv(
7
- _izContext,
8
- flowSchema,
9
- saveFilePath
10
- ),
11
- createFlowSchemaLambdaSyncHandlerInv(_izContext, flowSchema, saveFilePath)
6
+ createFlowSchemaLambdaSyncFunctionYamlInv(_izContext, flowSchema, appPath),
7
+ createFlowSchemaLambdaSyncHandlerInv(_izContext, flowSchema, appPath)
12
8
  ];
13
9
 
14
10
  return component.flat();
@@ -55,7 +55,7 @@ const templatePath = path.join(__dirname, 'template.ejs');
55
55
  * @return {{templatePath, templateData,setting}}
56
56
  */
57
57
 
58
- async function createSourceParams(_izContext, flowSchema, srcPath) {
58
+ async function createSourceParams(_izContext, flowSchema, appPath) {
59
59
  let createSources = [];
60
60
  let functionName = 'Process' + upperCase(flowSchema.flowTag);
61
61
  let handlerType = upperCase(HANDLER.hdrSqs);
@@ -64,7 +64,7 @@ async function createSourceParams(_izContext, flowSchema, srcPath) {
64
64
  let objectSchema;
65
65
 
66
66
  let setting = {
67
- savePath: path.join(srcPath, SOURCE_PATH.appYaml),
67
+ savePath: path.join(appPath, SOURCE_PATH.appYaml),
68
68
  saveFileName: SAVE_FILE_NAME.flowSchemaYaml,
69
69
  fileExtension: '.yml',
70
70
  isAppend: true
@@ -78,6 +78,7 @@ async function createSourceParams(_izContext, flowSchema, srcPath) {
78
78
  handlerFilePath: path.join(
79
79
  SOURCE_PATH.resourceLocationFlowSchema,
80
80
  upperCase(flowSchema.flowTag),
81
+ 'MainHandler/',
81
82
  'source/'
82
83
  ),
83
84
  functionName,
@@ -95,7 +96,7 @@ async function createSourceParams(_izContext, flowSchema, srcPath) {
95
96
  .getLocalObjectSchemas(
96
97
  _izContext,
97
98
  [flowSchema.objType.objectType],
98
- path.join(srcPath, './schemas')
99
+ path.join(appPath, 'src/schemas')
99
100
  )
100
101
  .then(res => res.records[0]);
101
102
  if (!objectSchema) {
@@ -36,7 +36,7 @@ const dsqTemplatePath = path.join(__dirname, 'DsqHandlerTemplate.ejs');
36
36
  * @param {Object} objectSchema
37
37
  * @return {{templatePath, templateData,setting}}
38
38
  */
39
- function createParamsForCreateSource(_izContext, flowSchema, srcPath) {
39
+ function createParamsForCreateSource(_izContext, flowSchema, appPath) {
40
40
  const createSources = [];
41
41
  const functionName = 'Process' + upperCase(flowSchema.flowTag);
42
42
  const handlerTypeSqs = upperCase(HANDLER.hdrSqs);
@@ -52,7 +52,7 @@ function createParamsForCreateSource(_izContext, flowSchema, srcPath) {
52
52
  },
53
53
  setting: {
54
54
  savePath: path.join(
55
- srcPath,
55
+ appPath,
56
56
  SOURCE_PATH.flowSchema,
57
57
  upperCase(flowSchema.flowTag),
58
58
  'MainHandler/',
@@ -74,7 +74,7 @@ function createParamsForCreateSource(_izContext, flowSchema, srcPath) {
74
74
  },
75
75
  setting: {
76
76
  savePath: path.join(
77
- srcPath,
77
+ appPath,
78
78
  SOURCE_PATH.flowSchema,
79
79
  upperCase(flowSchema.flowTag),
80
80
  'MainHandler/',