@izara_project/izara-market-library-service-schemas 1.0.52 → 1.0.54

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 (58) hide show
  1. package/package.json +5 -5
  2. package/src/GenerateCodeLibs/src/GenerateCodeLibs.js +1 -1
  3. package/src/reStructure/TemplateConfig.js +4 -1
  4. package/src/reStructure/TemplateData/Auth/generateAuthYml/data.js +58 -0
  5. package/src/reStructure/TemplateData/Auth/generateAuthYml/template.ejs +17 -0
  6. package/src/reStructure/TemplateData/Auth/generateTemplateData.js +51 -0
  7. package/src/reStructure/TemplateData/EndpointPerService/handler/api/template.ejs +2 -1
  8. package/src/reStructure/TemplateData/EndpointPerService/handler/dsq/template.ejs +2 -1
  9. package/src/reStructure/TemplateData/EndpointPerService/handler/inv/template.ejs +2 -0
  10. package/src/reStructure/TemplateData/EndpointPerService/handler/sqs/template.ejs +2 -0
  11. package/src/reStructure/TemplateData/EndpointPerService/mainFunction/create/template.ejs +52 -41
  12. package/src/reStructure/TemplateData/EndpointPerService/mainFunction/delete/template.ejs +3 -1
  13. package/src/reStructure/TemplateData/EndpointPerService/mainFunction/get/template.ejs +4 -4
  14. package/src/reStructure/TemplateData/EndpointPerService/mainFunction/update/template.ejs +4 -1
  15. package/src/reStructure/TemplateData/EndpointPerService/yaml/data.js +2 -2
  16. package/src/reStructure/TemplateData/EndpointPerService/yaml/template.ejs +12 -14
  17. package/src/reStructure/TemplateData/externalService/lambdaRole/data.js +22 -6
  18. package/src/reStructure/TemplateData/externalService/snsTopicSubscriptions/template.ejs +2 -2
  19. package/src/reStructure/TemplateData/flowSchema/externalTopic/Process/functionYaml/data.js +13 -10
  20. package/src/reStructure/TemplateData/flowSchema/externalTopic/Process/handler/data.js +1 -46
  21. package/src/reStructure/TemplateData/flowSchema/externalTopic/Process/handler/template.ejs +4 -1
  22. package/src/reStructure/TemplateData/flowSchema/externalTopic/sns-in-sqs/data.js +8 -12
  23. package/src/reStructure/TemplateData/flowSchema/{flowSchemaOwnTopic/EndpointComponent/mainFunction → flowSchemaMainFunction}/data.js +5 -5
  24. package/src/reStructure/TemplateData/flowSchema/{flowSchemaOwnTopic/EndpointComponent/mainFunction → flowSchemaMainFunction}/template.ejs +7 -12
  25. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComponent/functionYaml/data.js +12 -8
  26. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComponent/handler/template.ejs +6 -2
  27. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaComponent/functionYaml/data.js +1 -1
  28. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaComponent/handler/data.js +1 -1
  29. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaComponent/handler/template.ejs +1 -1
  30. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaComponent/mainFunction/data.js +1 -1
  31. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaComponent/mainFunction/template.ejs +1 -1
  32. package/src/reStructure/TemplateData/flowSchema/flowStep/functionYaml/data.js +1 -1
  33. package/src/reStructure/TemplateData/flowSchema/flowStep/handler/template.ejs +7 -1
  34. package/src/reStructure/TemplateData/flowSchema/flowStep/mainFunction/data.js +2 -2
  35. package/src/reStructure/TemplateData/flowSchema/flowStep/mainFunction/template.ejs +2 -7
  36. package/src/reStructure/TemplateData/flowSchema/generateTemplateData.js +37 -24
  37. package/src/reStructure/TemplateData/flowSchema/lambdaSync/Api/functionYaml/data.js +79 -0
  38. package/src/reStructure/TemplateData/flowSchema/lambdaSync/{functionYaml/templateApi.ejs → Api/functionYaml/template.ejs} +11 -5
  39. package/src/reStructure/TemplateData/flowSchema/lambdaSync/{handler → Api/handler}/data.js +7 -33
  40. package/src/reStructure/TemplateData/flowSchema/lambdaSync/{handler/templateApi.ejs → Api/handler/template.ejs} +28 -24
  41. package/src/reStructure/TemplateData/flowSchema/lambdaSync/Inv/functionYaml/data.js +78 -0
  42. package/src/reStructure/TemplateData/flowSchema/lambdaSync/Inv/handler/data.js +58 -0
  43. package/src/reStructure/TemplateData/flowSchema/lambdaSync/{handler/templateInv.ejs → Inv/handler/template.ejs} +11 -5
  44. package/src/reStructure/TemplateData/flowSchema/webSocketComplete/functionYaml/data.js +15 -7
  45. package/src/reStructure/TemplateData/propertyValueSchema/relationshipPropertyValueSchema/data.js +1 -1
  46. package/src/reStructure/TemplateData/relationshipPerAction/create/action/mainFunction/template.ejs +9 -1
  47. package/src/reStructure/TemplateData/relationshipPerAction/create/complete/mainFunction/template.ejs +5 -1
  48. package/src/reStructure/TemplateData/relationshipPerAction/get/action/mainFunction/template.ejs +9 -10
  49. package/src/reStructure/TemplateData/flowSchema/externalTopic/Process/mainFunction/data.js +0 -75
  50. package/src/reStructure/TemplateData/flowSchema/externalTopic/Process/mainFunction/template.ejs +0 -98
  51. package/src/reStructure/TemplateData/flowSchema/externalTopic/sns-in-sqs/sqsTemplate.ejs +0 -52
  52. package/src/reStructure/TemplateData/flowSchema/lambdaSync/functionYaml/data.js +0 -128
  53. package/src/reStructure/TemplateData/flowSchema/lambdaSync/mainFunction/data.js +0 -74
  54. package/src/reStructure/TemplateData/flowSchema/lambdaSync/mainFunction/template.ejs +0 -96
  55. /package/src/reStructure/TemplateData/flowSchema/lambdaSync/{functionYaml/templateInv.ejs → Inv/functionYaml/template.ejs} +0 -0
  56. /package/src/reStructure/TemplateData/flowSchema/{templateBystatusType → templateByStatusType}/statusFieldTemplate.ejs +0 -0
  57. /package/src/reStructure/TemplateData/flowSchema/{templateBystatusType → templateByStatusType}/storedCacheTemplate.ejs +0 -0
  58. /package/src/reStructure/TemplateData/flowSchema/{templateBystatusType → templateByStatusType}/triggerCacheTemplate.ejs +0 -0
@@ -55,52 +55,7 @@ async function data(_izContext, flowSchema, srcPath) {
55
55
  async function createSourceParams(_izContext, flowSchema, srcPath) {
56
56
  let functionName = "Process" + upperCase(flowSchema.flowTag)
57
57
  let handlerType = upperCase(HANDLER.hdrSqs)
58
- let additionalResourcePermission = defaultIamRolePerAction();
59
58
  let queueName = upperCase(flowSchema.flowTag) + handlerType;
60
- additionalResourcePermission.push(
61
- createIamRole(
62
- {
63
- [RESOURCE_CLASSES.sqs]: Object.values(SQS_RESOURCE)
64
- },
65
- [
66
- resourceNames(RESOURCE_CLASSES.sqs, queueName),
67
- resourceNames(RESOURCE_CLASSES.sqs, queueName + "DLQ")
68
- ]
69
- ),
70
- createIamRole(
71
- {
72
- [RESOURCE_CLASSES.lambda]: Object.values(LAMBDA_RESOURCE)
73
- },
74
- [
75
- resourceNames(RESOURCE_CLASSES.lambda, 'CreateHdrInv')
76
- ]
77
- ),
78
- )
79
-
80
- if (flowSchema.statusType === "storedCache") {
81
- let tableStroedCaches = [];
82
- let objectSchema = await getObjectSchema.getLocalObjectSchemas(_izContext, [flowSchema.objType.objectType], path.join(srcPath, "./schemas")).then(res => res.records[0])
83
- if (!objectSchema) {
84
- throw new NoRetryError('ObjectSchema not found')
85
- }
86
- for (const storageResource of Object.values(objectSchema.storageResources)) {
87
- if (storageResource.storageType === STORAGE_TYPES.dynamoDB) {
88
- if (!tableStroedCaches.includes(storageResource.tableName)) {
89
- tableStroedCaches.push(storageResource.tableName)
90
- }
91
- }
92
- }
93
-
94
- additionalResourcePermission.push(
95
- createIamRole(
96
- {
97
- [RESOURCE_CLASSES.dynamoDbTable]: Object.values(DYNAMO_RESOURCE)
98
- },
99
- tableStroedCaches.map(
100
- tableName => resourceNames(RESOURCE_CLASSES.dynamoDbTable, tableName))
101
- )
102
- )
103
- }
104
59
 
105
60
  return {
106
61
  templatePath: templatePath,
@@ -110,7 +65,7 @@ async function createSourceParams(_izContext, flowSchema, srcPath) {
110
65
  queueName
111
66
  },
112
67
  setting: {
113
- savePath: path.join(srcPath, SOURCE_PATH.flowSchema, flowSchema.flowTag, "source/"),
68
+ savePath: path.join(srcPath, SOURCE_PATH.flowSchema, upperCase(flowSchema.flowTag), "source/"),
114
69
  saveFileName: `${functionName}_${handlerType}`,
115
70
  fileExtension: ".js",
116
71
  isAppend: false
@@ -28,7 +28,10 @@ const Logger = require('@izara_project/izara-core-library-logger');
28
28
  const <%- functionName %> = require('./<%- functionName %>_Main')
29
29
 
30
30
  // validate event properties in body.Message of sqs event
31
- let perRecordsValidatorSchema = {}
31
+ let perRecordsValidatorSchema = {
32
+ //(<validatorSchema>)
33
+ //(</validatorSchema>)
34
+ }
32
35
  middleware.setValidatorSchema(recordHandlerSharedLib.baseValidatorSchema());
33
36
 
34
37
  module.exports.main = middleware.wrap(async (event, context, callback) => {
@@ -31,8 +31,6 @@ const STORAGE_TYPES = {
31
31
  graph: "graph"
32
32
  }
33
33
 
34
- const snsTemplatePath = path.join(__dirname, '../../../resourceYaml/sns-in-sqs/snsTemplate.ejs');
35
- const subscriptionSqsTemplatePath = path.join(__dirname, './sqsTemplate.ejs');
36
34
  const template = path.join(__dirname, "./template.ejs") // !! <----- Add here
37
35
 
38
36
  const { SOURCE_PATH, SAVE_FILE_NAME, FUNCTION_NAME, HANDLER } = require('../../../../../MainLibs/src/Consts.js');
@@ -69,19 +67,17 @@ function createDataForDefaultSnsInSqs(_izContext, flowSchema, srcPath) {
69
67
  )
70
68
  }
71
69
 
72
- resultsForCreateDefaultSnsInSqs.push({
73
- templatePath: template,
74
- templateData: {
75
- queueName: upperCase(flowSchema.flowTag) + "CompleteHdrSqs",
76
- },
77
- setting: setting
78
- })
79
-
80
-
70
+ if (flowSteps.includes("Out") && flowSchema.outputTopic === true) {
71
+ generatedSnsTopicInForFlowSchema.push(
72
+ {
73
+ queueName: upperCase(flowSchema.flowTag) + "Complete" + upperCase(HANDLER.hdrSqs)
74
+ }
75
+ )
76
+ }
81
77
 
82
78
  for (let defaultSnsInSqsData of generatedSnsTopicInForFlowSchema) {
83
79
  resultsForCreateDefaultSnsInSqs.push({
84
- templatePath: snsTemplatePath,
80
+ templatePath: template,
85
81
  templateData: defaultSnsInSqsData,
86
82
  setting: setting
87
83
  })
@@ -18,14 +18,14 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
18
18
  'use strict';
19
19
  const path = require('path');
20
20
  const NoRetryError = require('@izara_project/izara-core-library-core').NoRetryError
21
- const { SOURCE_PATH, FUNCTION_NAME, HANDLER } = require('../../../../../../MainLibs/src/Consts');
22
- const { firstLetterLowerCase: lowerCase, firstLetterUpperCase: upperCase } = require("../../../../../../MainLibs/src/Utils")
21
+ const { SOURCE_PATH, FUNCTION_NAME, HANDLER } = require('../../../../MainLibs/src/Consts');
22
+ const { firstLetterLowerCase: lowerCase, firstLetterUpperCase: upperCase } = require("../../../../MainLibs/src/Utils")
23
23
  const templatePath = path.join(__dirname, "template.ejs");
24
24
  const getObjectSchema = require('@izara_project/izara-core-library-service-schemas/src/GetObjectSchema');
25
25
  const { STORAGE_TYPES } = require('@izara_project/izara-core-library-service-schemas/src/Consts');
26
- const statusFieldTemplate = path.join(__dirname, "../../../templateBystatusType/statusFieldTemplate.ejs")
27
- const storedCacheTemplate = path.join(__dirname, "../../../templateBystatusType/storedCacheTemplate.ejs")
28
- const triggerCacheTemplate = path.join(__dirname, "../../../templateBystatusType/triggerCacheTemplate.ejs")
26
+ const statusFieldTemplate = path.join(__dirname, "../templateByStatusType/statusFieldTemplate.ejs")
27
+ const storedCacheTemplate = path.join(__dirname, "../templateByStatusType/storedCacheTemplate.ejs")
28
+ const triggerCacheTemplate = path.join(__dirname, "../templateByStatusType/triggerCacheTemplate.ejs")
29
29
 
30
30
  /**
31
31
  * receive objectSchema
@@ -18,29 +18,25 @@ along with this program. If not, see
18
18
 
19
19
  'use strict';
20
20
 
21
- const hash = require('@izara_project/izara-shared-core').objectHash;
22
21
  const getObjectSchema = require('@izara_project/izara-core-library-service-schemas/src/GetObjectSchema');
23
-
24
22
  const dynamodbSharedLib = require('@izara_project/izara-core-library-dynamodb');
25
23
  const snsSharedLib = require('@izara_project/izara-core-library-sns');
26
24
  const sqsSharedLib = require('@izara_project/izara-core-library-sqs');
27
25
  const asyncFlowSharedLib = require('@izara_project/izara-core-library-asynchronous-flow');
28
26
  const callingFlowSharedLib = require('@izara_project/izara-core-library-calling-flow');
29
27
  const lambdaSharedLib = require('@izara_project/izara-core-library-lambda');
30
- const storedCacheSharedLib = require('@izara_project/izara-core-library-stored-cache')
31
- const triggeredCacheSharedLib = require('@izara_project/izara-core-library-trigger-cache')
32
28
  const externalRequest = require('@izara_project/izara-core-library-external-request');
33
29
  const sns = externalRequest.sns
34
30
  const sqs = externalRequest.sqs
35
31
  const lambda = externalRequest.lambda
36
- const { postToConnection } = require("../../../libs/source/GenerateCodeLibs");
37
- const utils = require('@izara_project/izara-market-library-service-schemas/src/MainLibs/src/Utils')
38
32
  const NoRetryError = require('@izara_project/izara-core-library-core').NoRetryError
39
- const { v4: uuidv4 } = require('uuid')
40
- const coreConsts = require("@izara_project/izara-core-library-core/src/Consts");
41
- const { TOPIC_NAME_GENERATE_CODE } = require('@izara_project/izara-market-library-service-schemas/src/GenerateCodeLibs/src/Consts')
42
- const consts = require('@izara_project/izara-middleware/src/MiddlewareCore/Consts')
33
+ <% if (statusType === "triggerCache") { -%>
34
+ const triggeredCacheSharedLib = require('@izara_project/izara-core-library-trigger-cache')
35
+ <% } else if (statusType === "statusField") { -%>
43
36
  const { createFieldNamesFromRequestParamsByObjectSchema } = require('@izara_project/izara-market-library-service-schemas/src/GenerateCodeLibs/src/GenerateCodeLibs.js')
37
+ <% } else if (statusType === "storedCache") { -%>
38
+ const storedCacheSharedLib = require('@izara_project/izara-core-library-stored-cache')
39
+ <% } %>
44
40
  //(<optionalRequire>)
45
41
  //(</optionalRequire>)
46
42
  /**
@@ -63,7 +59,7 @@ module.exports.<%- functionName %> = async (
63
59
  requestParams,
64
60
  //(<additionalParams>)
65
61
  //(</additionalParams>)
66
- callingFlowConfig = {},
62
+ callingFlowConfig = {},
67
63
  ) => {
68
64
 
69
65
  try {
@@ -87,7 +83,6 @@ module.exports.<%- functionName %> = async (
87
83
  }) %>
88
84
  <% } %>
89
85
 
90
-
91
86
  //(<endpointHook>)
92
87
  //(</endpointHook>)
93
88
 
@@ -59,6 +59,7 @@ async function createSourceParams(_izContext, flowSchema, srcPath) {
59
59
  let additionalResourcePermission = defaultIamRolePerAction();
60
60
  let route = upperCase(flowSchema.flowTag);
61
61
  let queueName = upperCase(flowSchema.flowTag) + handlerType;
62
+
62
63
  additionalResourcePermission.push(
63
64
  createIamRole(
64
65
  {
@@ -69,14 +70,6 @@ async function createSourceParams(_izContext, flowSchema, srcPath) {
69
70
  resourceNames(RESOURCE_CLASSES.sqs, queueName + "DLQ")
70
71
  ]
71
72
  ),
72
- createIamRole(
73
- {
74
- [RESOURCE_CLASSES.lambda]: Object.values(LAMBDA_RESOURCE)
75
- },
76
- [
77
- resourceNames(RESOURCE_CLASSES.lambda, 'CreateHdrInv')
78
- ]
79
- ),
80
73
  )
81
74
 
82
75
  if (flowSchema.statusType === "storedCache") {
@@ -102,6 +95,17 @@ async function createSourceParams(_izContext, flowSchema, srcPath) {
102
95
  tableName => resourceNames(RESOURCE_CLASSES.dynamoDbTable, tableName))
103
96
  )
104
97
  )
98
+ } else if (flowSchema.statusType === "statusField") {
99
+ additionalResourcePermission.push(
100
+ createIamRole(
101
+ {
102
+ [RESOURCE_CLASSES.lambda]: Object.values(LAMBDA_RESOURCE)
103
+ },
104
+ [
105
+ resourceNames(RESOURCE_CLASSES.lambda, 'CreateHdrInv')
106
+ ]
107
+ )
108
+ )
105
109
  }
106
110
 
107
111
  return {
@@ -24,11 +24,14 @@ const izara = require("@izara_project/izara-middleware");
24
24
  const middleware = izara.middlewareHandler;
25
25
  const recordHandlerSharedLib = require("@izara_project/izara-core-library-record-handler")
26
26
  const Logger = require('@izara_project/izara-core-library-logger');
27
-
27
+ const callingFlowSharedLib = require('@izara_project/izara-core-library-calling-flow');
28
28
  const <%- functionName %> = require('./<%- functionName %>_Main')
29
29
 
30
30
  // validate event properties in body.Message of sqs event
31
- let perRecordsValidatorSchema = {}
31
+ let perRecordsValidatorSchema = {
32
+ //(<validatorSchema>)
33
+ //(</validatorSchema>)
34
+ }
32
35
  middleware.setValidatorSchema(recordHandlerSharedLib.baseValidatorSchema());
33
36
 
34
37
  module.exports.main = middleware.wrap(async (event, context, callback) => {
@@ -55,6 +58,7 @@ module.exports.main = middleware.wrap(async (event, context, callback) => {
55
58
  passOnProperties.push(record.body.Message)
56
59
  //(<additionalParams>)
57
60
  //(</additionalParams>)
61
+ passOnProperties.push(callingFlowSharedLib.addCallingFlowToPassOnProperties(record.body.Message));
58
62
  record._izContext.logger.debug('passOnProperties in handler', passOnProperties);
59
63
 
60
64
  // call recordHandlerSharedLib.recordHandler with 3 parameters and return promise(resolve)
@@ -98,7 +98,7 @@ function createSourceParams(_izContext, flowSchema, srcPath) {
98
98
  return {
99
99
  templatePath: templatePath,
100
100
  templateData: {
101
- resourceLocation: path.join(SOURCE_PATH.resourceLocationFlowSchema, flowSchema.flowTag, "source/"),
101
+ resourceLocation: path.join(SOURCE_PATH.resourceLocationFlowSchema, upperCase(flowSchema.flowTag), "source/"),
102
102
  functionName,
103
103
  handlerType,
104
104
  additionalResourcePermission,
@@ -47,7 +47,7 @@ function createParamsForCreateSource(_izContext, flowSchema, srcPath) {
47
47
  route
48
48
  },
49
49
  setting: {
50
- savePath: path.join(srcPath, SOURCE_PATH.flowSchema, flowSchema.flowTag, "source/"),
50
+ savePath: path.join(srcPath, SOURCE_PATH.flowSchema, upperCase(flowSchema.flowTag), "source/"),
51
51
  saveFileName: `${functionName}_${handlerType}`,
52
52
  fileExtension: ".js",
53
53
  isAppend: false
@@ -61,9 +61,9 @@ module.exports.main = middleware.wrap(async (event, context, callback) => {
61
61
  await <%- functionName %>.<%- functionName %>(
62
62
  event._izContext,
63
63
  eventParams,
64
- callingFlowSharedLib.addCallingFlowToPassOnProperties(callingFlow)
65
64
  //(<additionalParams>)
66
65
  //(</additionalParams>)
66
+ callingFlowSharedLib.addCallingFlowToPassOnProperties(callingFlow)
67
67
  )
68
68
 
69
69
  break
@@ -60,7 +60,7 @@ function createParamsForCreateSource(_izContext, flowSchema, srcPath) {
60
60
  functionName
61
61
  },
62
62
  setting: {
63
- savePath: path.join(srcPath, SOURCE_PATH.flowSchema, flowSchema.flowTag, "source/"),
63
+ savePath: path.join(srcPath, SOURCE_PATH.flowSchema, upperCase(flowSchema.flowTag), "source/"),
64
64
  saveFileName: `${functionName}_Main`,
65
65
  fileExtension: ".js",
66
66
  isAppend: false
@@ -55,9 +55,9 @@ const { postToConnection } = require('../../../libs/source/GenerateCodeLibs')
55
55
  module.exports.<%- functionName %> = async (
56
56
  _izContext,
57
57
  requestParams,
58
- callingFlowConfig = {},
59
58
  //(<additionalParams>)
60
59
  //(</additionalParams>)
60
+ callingFlowConfig = {},
61
61
  ) => {
62
62
 
63
63
  try {
@@ -87,7 +87,7 @@ function createSourceParams(_izContext, flowTag, flowStep, srcPath) {
87
87
  ]
88
88
  },
89
89
  [
90
- resourceNames(RESOURCE_CLASSES.sns, topicIn + "_In")
90
+ resourceNames(RESOURCE_CLASSES.sns, topicIn)
91
91
  ]
92
92
  ),
93
93
  createIamRole(
@@ -28,7 +28,10 @@ const Logger = require('@izara_project/izara-core-library-logger');
28
28
  const <%- functionName %> = require('./<%- functionName %>_Main')
29
29
 
30
30
  // validate event properties in body.Message of sqs event
31
- let perRecordsValidatorSchema = {}
31
+ let perRecordsValidatorSchema = {
32
+ //(<validatorSchema>)
33
+ //(</validatorSchema>)
34
+ }
32
35
  middleware.setValidatorSchema(recordHandlerSharedLib.baseValidatorSchema());
33
36
 
34
37
  module.exports.main = middleware.wrap(async (event, context, callback) => {
@@ -53,6 +56,9 @@ module.exports.main = middleware.wrap(async (event, context, callback) => {
53
56
 
54
57
  // add argument (to invoke lambda) to passOnProperties[]
55
58
  passOnProperties.push(record.body.Message)
59
+ //(<additionalParams>)
60
+ //(</additionalParams>)
61
+ passOnProperties.push(callingFlowSharedLib.addCallingFlowToPassOnProperties(record.body.Message));
56
62
  record._izContext.logger.debug('passOnProperties in handler', passOnProperties);
57
63
 
58
64
  // call recordHandlerSharedLib.recordHandler with 3 parameters and return promise(resolve)
@@ -73,8 +73,8 @@ function data(_izContext, flowSchema, srcPath) {
73
73
  }
74
74
 
75
75
  function createParamsForCreateSource(_izContext, flowTag, flowStep, srcPath) {
76
- let functionName = upperCase(flowTag)
77
- let topicArn = `${upperCase(flowStep)}_In`
76
+ let functionName = upperCase(flowStep)
77
+ let topicArn = `${upperCase(flowStep)}`
78
78
 
79
79
  return {
80
80
  templatePath: templatePath,
@@ -26,15 +26,10 @@ const snsSharedLib = require('@izara_project/izara-core-library-sns');
26
26
  const asyncFlowSharedLib = require('@izara_project/izara-core-library-asynchronous-flow');
27
27
  const callingFlowSharedLib = require('@izara_project/izara-core-library-calling-flow');
28
28
  const lambdaSharedLib = require('@izara_project/izara-core-library-lambda');
29
- const storedCacheSharedLib = require('@izara_project/izara-core-library-stored-cache')
30
29
  const externalRequest = require('@izara_project/izara-core-library-external-request');
31
30
  const sns = externalRequest.sns
32
-
33
- const utils = require('@izara_project/izara-market-library-service-schemas/src/MainLibs/src/Utils')
34
31
  const NoRetryError = require('@izara_project/izara-core-library-core').NoRetryError
35
- const coreConsts = require("@izara_project/izara-core-library-core/src/Consts");
36
- const { TOPIC_NAME_GENERATE_CODE } = require('@izara_project/izara-market-library-service-schemas/src/GenerateCodeLibs/src/Consts')
37
- const { postToConnection } = require('../../../libs/source/GenerateCodeLibs')
32
+
38
33
  //(<optionalRequire>)
39
34
  //(</optionalRequire>)
40
35
  /**
@@ -55,9 +50,9 @@ const { postToConnection } = require('../../../libs/source/GenerateCodeLibs')
55
50
  module.exports.<%- functionName %> = async (
56
51
  _izContext,
57
52
  requestParams,
58
- callingFlowConfig = {},
59
53
  //(<additionalParams>)
60
54
  //(</additionalParams>)
55
+ callingFlowConfig = {},
61
56
  ) => {
62
57
 
63
58
  try {
@@ -69,21 +69,21 @@ const createConfirmAfterUploadS3FunctionYaml = require('./components/upload/conf
69
69
  const createConfirmAfterUploadS3Handler = require('./components/upload/confirmReserved/handler/data');
70
70
  const createConfirmAfterUploadS3MainFunction = require('./components/upload/confirmReserved/mainFunction/data');
71
71
  const createConfirmAfterUploadS3Queue = require('./components/upload/confirmReserved/queue/data');
72
-
73
72
  // flowSchema ExternalTopic components //
74
73
  const createExternalSqsFunctionYaml = require('./externalTopic/Process/functionYaml/data');
75
74
  const createExternalSqsHandler = require('./externalTopic/Process/handler/data');
76
- const createExternalSqsMainFunction = require('./externalTopic/Process/mainFunction/data');
77
75
  const createExternalSqsCompleteFunctionYaml = require("./externalTopic/Complete/functionYaml/data");
78
76
  const createExternalSqsCompleteHandler = require("./externalTopic/Complete/handler/data");
79
77
  const createExternalSqsCompleteMainFunction = require("./externalTopic/Complete/mainFunction/data");
80
78
  const createExternalTopicSnsInSqs = require('./externalTopic/sns-in-sqs/data');
81
79
  const createExternalTopicSnsOut = require('./externalTopic/sns-out/data')
82
80
 
81
+ const createFlowSchemaEndpointMainFunction = require('./flowSchemaMainFunction/data');
82
+
83
83
  // flowSchema OwnTopic component
84
+ const createFlowSchemaOwnTopicMainFunction = require('./flowSchemaOwnTopic/FlowSchemaComponent/mainFunction/data');
84
85
  const createFlowSchemaOwnTopicFunctionYaml = require('./flowSchemaOwnTopic/FlowSchemaComponent/functionYaml/data');
85
86
  const createFlowSchemaOwnTopicHandler = require('./flowSchemaOwnTopic/FlowSchemaComponent/handler/data');
86
- const createFlowSchemaOwnTopicMainFunction = require('./flowSchemaOwnTopic/FlowSchemaComponent/mainFunction/data');
87
87
 
88
88
  // flowSchema OwnTopicComplete component
89
89
  const createWebSocketCompleteMainFunctionYaml = require("./webSocketComplete/functionYaml/data");
@@ -94,7 +94,6 @@ const createWebSocketCompleteMainSqs = require('./webSocketComplete/sqs/data');
94
94
 
95
95
  const createFlowSchemaOwnTopicEndpointFunctionYaml = require('./flowSchemaOwnTopic/EndpointComponent/functionYaml/data');
96
96
  const createFlowSchemaOwnTopicEndpointHandler = require('./flowSchemaOwnTopic/EndpointComponent/handler/data');
97
- const createFlowSchemaOwnTopicEndpointMainFunction = require('./flowSchemaOwnTopic/EndpointComponent/mainFunction/data');
98
97
 
99
98
  // flowSchema OnwTopic flowStep component
100
99
  const createFlowSchemaFlowStepFunctionYaml = require('./flowStep/functionYaml/data');
@@ -114,13 +113,15 @@ const createFlowSchemaEventBridgeHandler = require('./eventBridge/handler/inv/da
114
113
  const createFlowSchemaEventBridgeMainFunction = require('./eventBridge/mainFunction/data');
115
114
 
116
115
  // flowSchema lambdaSync components
117
- const createFlowSchemaLambdaSyncFunctionYaml = require('./lambdaSync/functionYaml/data');
118
- const createFlowSchemaLambdaSyncHandler = require('./lambdaSync/handler/data');
119
- const createFlowSchemaLambdaSyncMainFunction = require('./lambdaSync/mainFunction/data');
116
+ const createFlowSchemaLambdaSyncFunctionYamlInv = require('./lambdaSync/Inv/functionYaml/data');
117
+ const createFlowSchemaLambdaSyncHandlerInv = require('./lambdaSync/Inv/handler/data');
118
+
119
+ const createFlowSchemaLambdaSyncFunctionYamlApi = require("./lambdaSync/Api/functionYaml/data");
120
+ const createFlowSchemaLambdaSyncHandlerApi = require("./lambdaSync/Api/handler/data");
120
121
 
121
122
  const createAwaitingMultipleStepDynamoDbData = require('./dynamoDb/data');
122
123
  // create record status Field Complete
123
- const createCreateObjectCompleteFuntionYaml = require('./CreateRecordComplete/functionYaml/data');
124
+ const createCreateObjectCompleteFunctionYaml = require('./CreateRecordComplete/functionYaml/data');
124
125
  const createCreateObjectCompleteHandler = require('./CreateRecordComplete/handler/data');
125
126
  const createCreateObjectCompleteMainFunction = require('./CreateRecordComplete/mainFunction/data');
126
127
  const createCreateObjectCompleteQueue = require('./CreateRecordComplete/queue/data');// flowSchema Register component //
@@ -177,7 +178,8 @@ async function generateCodeWithTemplate(_izContext, objSchemaPath) {
177
178
  for (const flowSchema of allLocalFlowSchemas.records) {
178
179
  // console.log("flowSchema in Generate TemplateData", flowSchema);
179
180
  const webSocketGenerateCodeLibs = createWebSocketGenerateCodeLibs(_izContext, flowSchema, saveFilePath)
180
- createSourceParams.push(...webSocketGenerateCodeLibs)
181
+ const flowSchemaEndpointMainFunction = await createFlowSchemaEndpointMainFunction(_izContext, flowSchema, saveFilePath);
182
+ createSourceParams.push(...webSocketGenerateCodeLibs, ...flowSchemaEndpointMainFunction)
181
183
 
182
184
  // event has [s3, extTopic, ownTopic, eventBridge, lambdaSync]
183
185
  for (const event of flowSchema.event) {
@@ -277,7 +279,7 @@ async function generateCodeWithTemplate(_izContext, objSchemaPath) {
277
279
  // ** External Topic ** //
278
280
  const externalSqsFunctionYaml = await createExternalSqsFunctionYaml(_izContext, flowSchema, saveFilePath);
279
281
  const externalSqsHandler = await createExternalSqsHandler(_izContext, flowSchema, saveFilePath);
280
- const externalSqsMainFunction = await createExternalSqsMainFunction(_izContext, flowSchema, saveFilePath);
282
+ // const externalSqsMainFunction = await createExternalSqsMainFunction(_izContext, flowSchema, saveFilePath);
281
283
  const externalTopicSnsInSqs = createExternalTopicSnsInSqs(_izContext, flowSchema, saveFilePath);
282
284
  const externalTopicSnsOut = createExternalTopicSnsOut(_izContext, flowSchema, saveFilePath);
283
285
 
@@ -288,14 +290,14 @@ async function generateCodeWithTemplate(_izContext, objSchemaPath) {
288
290
  const externalTopic = [
289
291
  ...externalSqsFunctionYaml,
290
292
  ...externalSqsHandler,
291
- ...externalSqsMainFunction,
293
+ // ...externalSqsMainFunction,
292
294
  ...externalTopicSnsInSqs,
293
295
  ...externalTopicSnsOut,
294
296
  // ...externalTopicCompleteFunctionYml, ...externalTopicCompleteHandler, ...externalTopicCompleteMainFunction
295
297
  ];
296
298
 
297
299
  createSourceParams.push(...externalTopic)
298
-
300
+ console.log("flowSchema external topic generated")
299
301
  } else if (event.includes("ownTopic")) {
300
302
 
301
303
  // flowSchema OwnTopic components
@@ -307,8 +309,7 @@ async function generateCodeWithTemplate(_izContext, objSchemaPath) {
307
309
  // flowSchemaOwnTopic Endpoint
308
310
  const flowSchemaOwnTopicEndpointFunctionYaml = await createFlowSchemaOwnTopicEndpointFunctionYaml(_izContext, flowSchema, saveFilePath);
309
311
  const flowSchemaOwnTopicEndpointHandler = createFlowSchemaOwnTopicEndpointHandler(_izContext, flowSchema, saveFilePath);
310
- const flowSchemaOwnTopicEndpointMainFunction = await createFlowSchemaOwnTopicEndpointMainFunction(_izContext, flowSchema, saveFilePath);
311
- const flowSchemaOwnTopicEndpointComponent = [...flowSchemaOwnTopicEndpointFunctionYaml, ...flowSchemaOwnTopicEndpointHandler, ...flowSchemaOwnTopicEndpointMainFunction]
312
+ const flowSchemaOwnTopicEndpointComponent = [...flowSchemaOwnTopicEndpointFunctionYaml, ...flowSchemaOwnTopicEndpointHandler]
312
313
 
313
314
  // flowSchemaOwnTopic EndpointComplete
314
315
  // const flowSchemaOwnTopicEndpointCompleteFuntionYaml = createFlowSchemaOwnTopicEndpointCompleteFuntionYaml(_izContext, flowSchema, saveFilePath);
@@ -344,20 +345,32 @@ async function generateCodeWithTemplate(_izContext, objSchemaPath) {
344
345
  // console.log("event eventBridge generated", JSON.stringify(eventBridgeResources, null, 2))
345
346
  console.log("event eventBridge generated")
346
347
  createSourceParams.push(...eventBridgeResources);
347
- } else if (event.includes("lambdaSync")) {
348
- const flowSchemaLambdaSyncFunctionYaml = await createFlowSchemaLambdaSyncFunctionYaml(_izContext, flowSchema, saveFilePath);
349
- const flowSchemaLambdaSyncHandler = createFlowSchemaLambdaSyncHandler(_izContext, flowSchema, saveFilePath);
350
- const flowSchemaLambdaSyncMainFunction = await createFlowSchemaLambdaSyncMainFunction(_izContext, flowSchema, saveFilePath);
348
+ } else if (event.includes("lambdaSyncInv")) {
349
+ const flowSchemaLambdaSyncFunctionYamlInv = createFlowSchemaLambdaSyncFunctionYamlInv(_izContext, flowSchema, saveFilePath);
350
+ const flowSchemaLambdaSyncHandlerInv = createFlowSchemaLambdaSyncHandlerInv(_izContext, flowSchema, saveFilePath);
351
+ // const flowSchemaLambdaSyncMainFunctionInv = createFlowSchemaLambdaSyncMainFunctionInv(_izContext, flowSchema, saveFilePath);
352
+
351
353
 
352
354
  // Group the resources
353
- const lambdaSyncResources = [
354
- ...flowSchemaLambdaSyncFunctionYaml,
355
- ...flowSchemaLambdaSyncHandler,
356
- ...flowSchemaLambdaSyncMainFunction
355
+ const lambdaSyncInvResources = [
356
+ flowSchemaLambdaSyncFunctionYamlInv,
357
+ flowSchemaLambdaSyncHandlerInv,
358
+ // flowSchemaLambdaSyncMainFunctionInv,
357
359
  ];
358
360
 
359
- console.log("event lambdaSync generated")
360
- createSourceParams.push(...lambdaSyncResources);
361
+ console.log("event lambdaSyncInv generated")
362
+ createSourceParams.push(...lambdaSyncInvResources);
363
+
364
+ } else if (event.includes("lambdaSyncApi")) {
365
+ const flowSchemaLambdaSyncFunctionYamlApi = createFlowSchemaLambdaSyncFunctionYamlApi(_izContext, flowSchema, saveFilePath);
366
+ const flowSchemaLambdaSyncHandlerApi = createFlowSchemaLambdaSyncHandlerApi(_izContext, flowSchema, saveFilePath);
367
+
368
+ const lambdaSyncApiResources = [
369
+ flowSchemaLambdaSyncFunctionYamlApi,
370
+ flowSchemaLambdaSyncHandlerApi,
371
+ ];
372
+ createSourceParams.push(...lambdaSyncApiResources)
373
+ console.log("event lambdaSyncApi generated")
361
374
  }
362
375
  }
363
376
 
@@ -0,0 +1,79 @@
1
+ /*
2
+ Copyright (C) 2020 Sven Mason <http://izara.io>
3
+
4
+ This program is free software: you can redistribute it and/or modify
5
+ it under the terms of the GNU Affero General Public License as
6
+ published by the Free Software Foundation, either version 3 of the
7
+ License, or (at your option) any later version.
8
+
9
+ This program is distributed in the hope that it will be useful,
10
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ GNU Affero General Public License for more details.
13
+
14
+ You should have received a copy of the GNU Affero General Public License
15
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
16
+ */
17
+
18
+ 'use strict';
19
+ const path = require('path');
20
+
21
+ const { FLOW_SCHEMA_HOOK_STATE, ACTIONS, HANDLER, STORAGE_TYPES } = require('@izara_project/izara-core-library-service-schemas/src/Consts')
22
+ const { firstLetterUpperCase: upperCase } = require('../../../../../../MainLibs/src/Utils')
23
+ const {
24
+ SOURCE_PATH,
25
+ defaultIamRolePerAction,
26
+ createIamRole,
27
+ RESOURCE_CLASSES,
28
+ SNS_RESOURCE,
29
+ resourceNames,
30
+ DYNAMO_RESOURCE,
31
+ SAVE_FILE_NAME,
32
+ FUNCTION_NAME,
33
+ shortNameHandler,
34
+ externalResourceYaml,
35
+ SOURCE_GENERATE_IAM_ROLE,
36
+ SQS_RESOURCE,
37
+ LAMBDA_RESOURCE
38
+ } = require('../../../../../../MainLibs/src/Consts');
39
+ const { NoRetryError } = require('@izara_project/izara-core-library-core');
40
+ const getObjectSchema = require('@izara_project/izara-core-library-service-schemas').getObjectSchema;
41
+
42
+ const templatePath = path.join(__dirname, "./template.ejs");
43
+ /**
44
+ * receive objectSchema
45
+ *
46
+ * @param {Object} objectSchema
47
+ * @return {{templatePath, templateData,setting}}
48
+ */
49
+
50
+ function data(_izContext, flowSchema, srcPath) {
51
+ return createSourceParamsApi(_izContext, flowSchema, srcPath)
52
+ }
53
+
54
+ function createSourceParamsApi(_izContext, flowSchema, srcPath) {
55
+ let functionName = "Process" + upperCase(flowSchema.flowTag)
56
+ let handlerType = upperCase(HANDLER.hdrApi)
57
+ let additionalResourcePermission = defaultIamRolePerAction();
58
+
59
+ return {
60
+ templatePath: templatePath,
61
+ templateData: {
62
+ resourceLocation: path.join(SOURCE_PATH.resourceLocationFlowSchema, upperCase(flowSchema.flowTag), "source/"),
63
+ functionName,
64
+ handlerType,
65
+ additionalResourcePermission,
66
+ functionNameConfig: upperCase(functionName) + upperCase(shortNameHandler(handlerType)),
67
+ roleName: upperCase(flowSchema.flowTag),
68
+ event: "post"
69
+ },
70
+ setting: {
71
+ savePath: path.join(srcPath, SOURCE_PATH.appYaml),
72
+ saveFileName: upperCase(SAVE_FILE_NAME.flowSchema),
73
+ fileExtension: ".yml",
74
+ isAppend: true
75
+ }
76
+ }
77
+ }
78
+
79
+ module.exports = data;
@@ -3,12 +3,18 @@
3
3
  handler: <%- join(resourceLocation, `${firstLetterUpperCase(functionName)}_${firstLetterUpperCase(handlerType)}.main`) %>
4
4
  name: ${self:custom.iz_resourcePrefix}<%- firstLetterUpperCase(functionName) %><%- firstLetterUpperCase(handlerType) %>
5
5
  events:
6
- - http:
7
- path: <%- firstLetterUpperCase(functionName) %>
6
+ - httpApi:
7
+ path: /<%- firstLetterLowerCase(functionName) %>/
8
8
  method: <%- event %>
9
- cors: true
10
- #<#<%- firstLetterUpperCase(functionName) _%><%- firstLetterUpperCase(handlerType) %>Authorizer#>
11
- #<#/<%- firstLetterUpperCase(functionName) _%><%- firstLetterUpperCase(handlerType) %>Authorizer#>
9
+ authorizer: authorizerServiceSchema
10
+ #<#<%- firstLetterUpperCase(functionName) _%><%- firstLetterUpperCase(handlerType) %>AppLevelAuthorizer#>
11
+ #<#/<%- firstLetterUpperCase(functionName) _%><%- firstLetterUpperCase(handlerType) %>AppLevelAuthorizer#>
12
+ - httpApi:
13
+ path: /<%- firstLetterLowerCase(functionName) %>/{targetUserId}
14
+ method: <%- event %>
15
+ authorizer: authorizerServiceSchema
16
+ #<#<%- firstLetterUpperCase(functionName) _%><%- firstLetterUpperCase(handlerType) %>UserLevelAuthorizer#>
17
+ #<#/<%- firstLetterUpperCase(functionName) _%><%- firstLetterUpperCase(handlerType) %>UserLevelAuthorizer#>
12
18
  role: <%- firstLetterUpperCase(roleName) _%>Role
13
19
  #<#<%- firstLetterUpperCase(functionName) %><%- firstLetterUpperCase(handlerType) %>IamRole#>
14
20
  #<#/<%- firstLetterUpperCase(functionName) %><%- firstLetterUpperCase(handlerType) %>IamRole#>