@izara_project/izara-market-library-service-schemas 1.0.34 → 1.0.35

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 (74) hide show
  1. package/package.json +1 -1
  2. package/src/GenerateCodeLibs/src/Consts.js +2 -1
  3. package/src/GenerateCodeLibs/src/GenerateCodeLibs.js +5 -5
  4. package/src/MainLibs/src/Consts.js +43 -10
  5. package/src/TemplateManager/src/attributeTree/relationshipSchema/data.js +1 -1
  6. package/src/reStructure/GenerateCode.js +1 -0
  7. package/src/reStructure/SchemaConfig.js +1 -0
  8. package/src/reStructure/TemplateData/EndpointPerService/handler/api/template.ejs +2 -2
  9. package/src/reStructure/TemplateData/EndpointPerService/handler/inv/template.ejs +2 -2
  10. package/src/reStructure/TemplateData/EndpointPerService/mainFunction/create/template.ejs +3 -0
  11. package/src/reStructure/TemplateData/attributeTreeSchema/generateTemplateData.js +28 -44
  12. package/src/reStructure/TemplateData/attributeTreeSchema/{mainAttributeTreeSchema → mainAttributeTree}/attributeLinkTemplate.ejs +3 -7
  13. package/src/reStructure/TemplateData/attributeTreeSchema/mainAttributeTree/data.js +134 -0
  14. package/src/reStructure/TemplateData/attributeTreeSchema/relationshipSchema/data.js +172 -0
  15. package/src/reStructure/TemplateData/attributeTreeSchema/relationshipSchema/template.ejs +7 -0
  16. package/src/reStructure/TemplateData/flowSchema/CreateRecordComplete/functionYaml/data.js +123 -0
  17. package/src/reStructure/TemplateData/flowSchema/CreateRecordComplete/functionYaml/template.ejs +20 -0
  18. package/src/reStructure/TemplateData/flowSchema/CreateRecordComplete/handler/data.js +57 -0
  19. package/src/reStructure/TemplateData/flowSchema/CreateRecordComplete/handler/template.ejs +85 -0
  20. package/src/reStructure/TemplateData/flowSchema/CreateRecordComplete/mainFunction/data.js +68 -0
  21. package/src/reStructure/TemplateData/flowSchema/CreateRecordComplete/mainFunction/template.ejs +96 -0
  22. package/src/reStructure/TemplateData/flowSchema/CreateRecordComplete/queue/data.js +77 -0
  23. package/src/reStructure/TemplateData/flowSchema/CreateRecordComplete/queue/template.ejs +49 -0
  24. package/src/reStructure/TemplateData/flowSchema/components/websocket/connect/handler/template.ejs +4 -4
  25. package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/complete/functionYaml/data.js +138 -0
  26. package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/complete/functionYaml/template.ejs +20 -0
  27. package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/complete/handler/data.js +55 -0
  28. package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/complete/handler/template.ejs +83 -0
  29. package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/complete/mainFunction/data.js +55 -0
  30. package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/complete/mainFunction/template.ejs +133 -0
  31. package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/sns-in/data.js +64 -0
  32. package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/sns-in/template.ejs +12 -0
  33. package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/statusFieldTemplate.ejs +19 -6
  34. package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/storedCacheTemplate.ejs +19 -2
  35. package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/subscriptionOutAll/data.js +76 -0
  36. package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/subscriptionOutAll/template.ejs +13 -0
  37. package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/wbs/functionYaml/data.js +142 -0
  38. package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/wbs/functionYaml/template.ejs +18 -0
  39. package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/wbs/handler/data.js +64 -0
  40. package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/wbs/handler/template.ejs +89 -0
  41. package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/wbs/mainFunction/data.js +55 -0
  42. package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/wbs/mainFunction/template.ejs +120 -0
  43. package/src/reStructure/TemplateData/flowSchema/eventBridge/functionYaml/data.js +26 -59
  44. package/src/reStructure/TemplateData/flowSchema/eventBridge/functionYaml/template.ejs +3 -3
  45. package/src/reStructure/TemplateData/flowSchema/eventBridge/handler/inv/data.js +8 -8
  46. package/src/reStructure/TemplateData/flowSchema/eventBridge/mainFunction/data.js +11 -9
  47. package/src/reStructure/TemplateData/flowSchema/eventBridge/mainFunction/template.ejs +3 -3
  48. package/src/reStructure/TemplateData/flowSchema/externalTopic/sns-in-sqs/data.js +3 -6
  49. package/src/reStructure/TemplateData/flowSchema/externalTopic/sqs/functionYaml/data.js +7 -9
  50. package/src/reStructure/TemplateData/flowSchema/externalTopic/sqs/functionYaml/template.ejs +2 -2
  51. package/src/reStructure/TemplateData/flowSchema/externalTopic/sqs/handler/data.js +2 -2
  52. package/src/reStructure/TemplateData/flowSchema/externalTopic/sqs/mainFunction/data.js +1 -1
  53. package/src/reStructure/TemplateData/flowSchema/externalTopic/websocket/functionYaml/data.js +8 -43
  54. package/src/reStructure/TemplateData/flowSchema/externalTopic/websocket/functionYaml/template.ejs +1 -1
  55. package/src/reStructure/TemplateData/flowSchema/externalTopic/websocket/handler/data.js +2 -2
  56. package/src/reStructure/TemplateData/flowSchema/externalTopic/websocket/handler/template.ejs +1 -0
  57. package/src/reStructure/TemplateData/flowSchema/externalTopic/websocket/mainFunction/data.js +7 -1
  58. package/src/reStructure/TemplateData/flowSchema/externalTopic/websocket/mainFunction/template.ejs +18 -7
  59. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComplete/mainFunction/data.js +3 -1
  60. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComponent/mainFunction/data.js +7 -1
  61. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComponent/mainFunction/template.ejs +52 -13
  62. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaCompleteComponent/functionYaml/template.ejs +2 -0
  63. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaComponent/mainFunction/data.js +1 -6
  64. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaComponent/mainFunction/template.ejs +1 -29
  65. package/src/reStructure/TemplateData/flowSchema/generateTemplateData.js +67 -6
  66. package/src/reStructure/TemplateData/generateRole/createSharedResource.js +20 -0
  67. package/src/reStructure/TemplateData/propertyNodeSchema/generateTemplateData.js +66 -0
  68. package/src/reStructure/TemplateData/propertyNodeSchema/objectPropertyNodeSchema/data.js +151 -0
  69. package/src/reStructure/TemplateData/propertyNodeSchema/objectPropertyNodeSchema/templateObjectPropertyNodeSchema.ejs +16 -0
  70. package/src/reStructure/TemplateData/propertyNodeSchema/relationshipPropertyNodeSchema/data.js +179 -0
  71. package/src/reStructure/TemplateData/propertyNodeSchema/relationshipPropertyNodeSchema/templateRelationshipPropertyNodeSchema.ejs +7 -0
  72. package/src/reStructure/libs/ValidateAddOnDataStructure.js +62 -0
  73. package/src/reStructure/TemplateData/attributeTreeSchema/mainAttributeTreeSchema/data.js +0 -188
  74. /package/src/reStructure/TemplateData/attributeTreeSchema/{mainAttributeTreeSchema → mainAttributeTree}/request.json +0 -0
@@ -0,0 +1,120 @@
1
+ /*
2
+ Copyright (C) 2020 Sven Mason <http: //izara.io>
3
+
4
+ This program is free software: you can redistribute it and/or modify
5
+ it under the terms of the GNU Affero General Public License as
6
+ published by the Free Software Foundation, either version 3 of the
7
+ License, or (at your option) any later version.
8
+
9
+ This program is distributed in the hope that it will be useful,
10
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ GNU Affero General Public License for more details.
13
+
14
+ You should have received a copy of the GNU Affero General Public License
15
+ along with this program. If not, see
16
+ <http: //www.gnu.org/licenses />.
17
+ */
18
+
19
+ 'use strict';
20
+
21
+ const hash = require("object-hash");
22
+ const { getObjectSchema } = require('@izara_project/izara-core-library-service-schemas');
23
+
24
+ const dynamodbSharedLib = require('@izara_project/izara-core-library-dynamodb');
25
+ const snsSharedLib = require('@izara_project/izara-core-library-sns');
26
+ const asyncFlowSharedLib = require('@izara_project/izara-core-library-asynchronous-flow');
27
+ const callingFlowSharedLib = require('@izara_project/izara-core-library-calling-flow');
28
+ const lambdaSharedLib = require('@izara_project/izara-core-library-lambda');
29
+
30
+ const externalRequest = require('@izara_project/izara-core-library-external-request');
31
+ const sns = externalRequest.sns
32
+
33
+ const utils = require('@izara_project/izara-market-library-service-schemas/src/MainLibs/src/Utils')
34
+ const NoRetryError = require('@izara_project/izara-core-library-core').NoRetryError
35
+ const { v4: uuidv4 } = require('uuid')
36
+ const coreConsts = require("@izara_project/izara-core-library-core/src/Consts");
37
+ const { TOPIC_NAME_GENERATE_CODE } = require('@izara_project/izara-market-library-service-schemas/src/GenerateCodeLibs/src/Consts')
38
+ /**
39
+ *
40
+ *
41
+ * description of function.
42
+ * @param {Object} _izContext
43
+ * @param {CorrelationIds} _izContext.correlationIds - property of _izContext
44
+ * @param {Logger} _izContext.logger - property of _izContext
45
+ * @param {Object} requestParams - request params
46
+ * @param {Object} requestParams.identifiers - identifiers for get data
47
+ * @param {Object} requestParams.additionalRequest - additionalRequest
48
+ *
49
+ *
50
+ * @returns {object} description of return value
51
+ */
52
+
53
+ module.exports.<%- functionMain%> = async (
54
+ _izContext,
55
+ requestParams,
56
+ callingFlowConfig = {},
57
+ //(<additionalParams>)
58
+ //(</additionalParams>)
59
+ ) => {
60
+ try {
61
+ //param {
62
+ // "action":register
63
+ // flowTag:"xxx"
64
+ // identifierTask:"xxxx",
65
+ // ...something
66
+ //}
67
+
68
+ // receive flowTag and identifiers
69
+ let flowSchema = await getObjectSchema.getFlowSchemaS3WithCache(_izContext, {
70
+ flowTag: requestParams.flowTag,
71
+ serviceTag: requestParams.serviceTag,
72
+ })
73
+
74
+ _izContext.logger.debug("flowSchema", flowSchema)
75
+ if (!flowSchema) {
76
+ throw new NoRetryError(`flowTag not found ${requestParams.flowTag}`)
77
+ }
78
+
79
+ switch (flowSchema.statusType) {
80
+ case "statusField":
81
+ let payload = {
82
+ identifiers: requestParams.identifiers,
83
+ objectType: flowSchema.objType.objectType
84
+ }
85
+ let result = await externalRequest.lambda.invokeSync(
86
+ _izContext,
87
+ await lambdaSharedLib.lambdaFunctionName(_izContext, "GetHdrInv", flowSchema.objType.serviceTag),
88
+ payload
89
+ )
90
+ if (!result) {
91
+ throw new NoRetryError(`statusField not found ${requestParams.identifiers}`)
92
+ }
93
+ return result
94
+ case "storedCache":
95
+ // if statusType=storedCache then query storedCache > post message to client -> remove connectionId if status = error || complete
96
+ const getStoredCache = await dynamodbSharedLib.getItem(
97
+ _izContext,
98
+ await dynamodbSharedLib.tableName(_izContext, flowSchema.flowTag + "Main"),
99
+ {
100
+ taskKey: requestParams.identifiers,
101
+ connectionId: requestParams.connectionId
102
+ }
103
+ )
104
+ if (!getStoredCache) {
105
+ throw new NoRetryError(`storedCache not found ${requestParams.identifiers}`)
106
+ }
107
+ return getStoredCache
108
+ case "none":
109
+ // if statusType=none -> post message to client ---- not remove connectionId when post message, can remove connectionId when cannot use connectionId only(user disconnect)
110
+ break
111
+ default:
112
+ throw new NoRetryError(`statusType not found ${flowSchema.statusType}`)
113
+ }
114
+
115
+ // post result to connectionId
116
+ } catch (err) {
117
+ _izContext.logger.error('error WebSocketInvoke: ', err)
118
+ throw (err)
119
+ }
120
+ }
@@ -51,9 +51,9 @@ function data(_izContext, flowSchema, srcPath) {
51
51
  }
52
52
 
53
53
  function createSourceParams(_izContext, flowSchema, srcPath) {
54
- const functionName = upperCase(flowSchema.flowTag);
55
- const action = SOURCE_GENERATE_IAM_ROLE.EventBridge;
56
- const functionNameConfig = upperCase(flowSchema.flowTag) + SOURCE_GENERATE_IAM_ROLE.EventBridge;
54
+ const functionName = upperCase(FUNCTION_NAME.flowSchemaEventBridge);
55
+ // const action = SOURCE_GENERATE_IAM_ROLE.EventBridge;
56
+ const functionNameConfig = upperCase(SOURCE_GENERATE_IAM_ROLE.EventBridge);
57
57
  const handlerType = HANDLER.hdrInv;
58
58
  const schedules = flowSchema.schedules;
59
59
 
@@ -85,25 +85,28 @@ function createSourceParams(_izContext, flowSchema, srcPath) {
85
85
 
86
86
  // Validate rate format for each schedule
87
87
  for (const schedule of schedules) {
88
- const rate = schedule.rate;
89
- if (rate.startsWith('rate')) {
90
- // Validate rate expression format: rate(value unit)
91
- if (!/^rate\(\d+\s+(minute|minutes|hour|hours|day|days)\)$/.test(rate)) {
92
- console.error(`Invalid rate format: ${rate}. Should be like 'rate(5 minutes)' or 'rate(1 day)'`);
93
- return;
94
- }
95
- } else if (rate.startsWith('cron')) {
96
- // Extract the cron components for more detailed validation
97
- const cronMatch = rate.match(/^cron\((.*)\)$/);
98
- if (!cronMatch) {
99
- console.error(`Invalid cron format: ${rate}. Should be like 'cron(0 10 * * ? *)'`);
100
- return;
101
- }
88
+ if (Array.isArray(schedule.rate) && schedule.rate.length <= 1) {
89
+ const rate = schedule.rate[0];
90
+
91
+ if (rate.startsWith('rate')) {
92
+ // Validate rate expression format: rate(value unit)
93
+ if (!/^rate\(\d+\s+(minute|minutes|hour|hours|day|days)\)$/.test(rate)) {
94
+ console.error(`Invalid rate format: ${rate}. Should be like 'rate(5 minutes)' or 'rate(1 day)'`);
95
+ return;
96
+ }
97
+ } else if (rate.startsWith('cron')) {
98
+ // Extract the cron components for more detailed validation
99
+ const cronMatch = rate.match(/^cron\((.*)\)$/);
100
+ if (!cronMatch) {
101
+ console.error(`Invalid cron format: ${rate}. Should be like 'cron(0 10 * * ? *)'`);
102
+ return;
103
+ }
102
104
 
103
- const cronParts = cronMatch[1].split(/\s+/);
104
- if (cronParts.length !== 6) {
105
- console.error(`Invalid cron expression: ${rate}. Must contain 6 components: minutes hours day-of-month month day-of-week year`);
106
- return;
105
+ const cronParts = cronMatch[1].split(/\s+/);
106
+ if (cronParts.length !== 6) {
107
+ console.error(`Invalid cron expression: ${rate}. Must contain 6 components: minutes hours day-of-month month day-of-week year`);
108
+ return;
109
+ }
107
110
  }
108
111
 
109
112
  } else {
@@ -115,16 +118,6 @@ function createSourceParams(_izContext, flowSchema, srcPath) {
115
118
 
116
119
  let additionalResourcePermission = defaultIamRolePerAction();
117
120
  additionalResourcePermission.push(
118
- createIamRole(
119
- {
120
- [RESOURCE_CLASSES.sns]: [
121
- SNS_RESOURCE.publish
122
- ]
123
- },
124
- [
125
- resourceNames(RESOURCE_CLASSES.sns, "InImportBatchMainCreate")
126
- ]
127
- ),
128
121
  createIamRole(
129
122
  {
130
123
  [RESOURCE_CLASSES.dynamoDbTable]: [
@@ -151,39 +144,13 @@ function createSourceParams(_izContext, flowSchema, srcPath) {
151
144
  )
152
145
  )
153
146
 
154
- if (flowSchema?.hook) {
155
- for (const [hookName, hookProperties] of Object.entries(flowSchema.hook)) {
156
- if (hookName === FLOW_SCHEMA_HOOK_STATE.beforeCreate) {
157
- for (const hookFunction of hookProperties.functionList) {
158
- if ((hookFunction.event.hasOwnProperty("initialEvent") && (hookFunction.event.initialEvent === true))) {
159
- if (hookFunction?.permission) {
160
- for (const permission of hookFunction.permission) {
161
- additionalResourcePermission.push(
162
- createIamRole(
163
- permission.action,
164
- permission.resource.map(resource =>
165
- externalResourceYaml(
166
- resource.resource,
167
- resource.resourceName,
168
- resource.serviceTag),
169
- permission.effect
170
- )
171
- )
172
- )
173
- }
174
- }
175
- }
176
- }
177
- }
178
- }
179
- }
180
147
  // console.log("additionalResourcePermission in createObjectS3", JSON.stringify(additionalResourcePermission))
181
148
  return {
182
149
  templatePath: templatePath,
183
150
  templateData: {
184
- resourceLocation: SOURCE_PATH.resourceLocationFlowSchemaEventBridge,
151
+ resourceLocation: path.join(SOURCE_PATH.resourceLocationFlowSchemaEventBridge, flowSchema.flowTag, "source/"),
185
152
  functionName,
186
- action,
153
+ // action,
187
154
  functionNameConfig: functionNameConfig,
188
155
  additionalResourcePermission,
189
156
  roleName: SOURCE_GENERATE_IAM_ROLE.EventBridge,
@@ -1,6 +1,6 @@
1
1
  <%_ const join = require('path').join; _%>
2
2
  <%- firstLetterUpperCase(functionNameConfig) %>:
3
- handler: <%- join(resourceLocation, `${functionName}${action}_${firstLetterUpperCase(handlerType)}.main`)%>
3
+ handler: <%- join(resourceLocation, `${functionName}_${firstLetterUpperCase(handlerType)}.main`)%>
4
4
  name: ${self:custom.iz_resourcePrefix}<%- firstLetterUpperCase(functionNameConfig) %>
5
5
  events:
6
6
  <%_ schedules.forEach((schedule) => { _%>
@@ -11,8 +11,8 @@
11
11
  input: <%- JSON.stringify(schedule.input) %>
12
12
  <%_ }) _%>
13
13
  role: <%- roleName %>Role
14
- #<#<%- functionName %><%- action %>IamRole#>
15
- #<#/<%- functionName %><%- action %>IamRole#>
14
+ #<#<%- functionName %>IamRole#>
15
+ #<#/<%- functionName %>IamRole#>
16
16
  <%_ function firstLetterUpperCase(text){
17
17
  return text.charAt(0).toUpperCase() + text.slice(1)
18
18
  } _%>
@@ -51,22 +51,22 @@ const templatePath = path.join(__dirname, "./template.ejs")
51
51
  function data(_izContext, flowSchema, srcPath) {
52
52
  const handler = HANDLER.hdrInv;
53
53
  const flowTag = flowSchema.flowTag;
54
- const action = SOURCE_GENERATE_IAM_ROLE.EventBridge;
55
- const functionName = flowTag + action;
56
- const fileName = `${upperCase(flowTag)}${upperCase(action)}_${upperCase(handler)}`;
54
+ // const action = SOURCE_GENERATE_IAM_ROLE.EventBridge;
55
+ const functionName = "EventBridge" + upperCase(handler);
56
+ // const fileName = `${upperCase(flowTag)}${upperCase(action)}_${upperCase(handler)}`;
57
57
  return [{
58
58
  templatePath: templatePath,
59
59
  templateData: {
60
60
  functionName: functionName,
61
61
  flowTag: flowTag,
62
- action: action,
62
+ // action: action,
63
63
  handler,
64
- roleName: SOURCE_GENERATE_IAM_ROLE.EventBridge,
65
- firstLetterUpperCase: upperCase,
64
+ // roleName: SOURCE_GENERATE_IAM_ROLE.EventBridge,
65
+ // firstLetterUpperCase: upperCase,
66
66
  },
67
67
  setting: {
68
- savePath: path.join(srcPath, SOURCE_PATH.flowSchemaEventBridge),
69
- saveFileName: fileName,
68
+ savePath: path.join(srcPath, SOURCE_PATH.flowSchemaEventBridge, flowSchema.flowTag, "source/"),
69
+ saveFileName: `EventBridge_${upperCase(handler)}`,
70
70
  fileExtension: '.js',
71
71
  isAppend: false
72
72
  }
@@ -32,7 +32,9 @@ const {
32
32
  consts: {
33
33
  DEFAULT_HANDLER_PER_ACTION,
34
34
  SOURCE_PATH,
35
- SOURCE_GENERATE_IAM_ROLE
35
+ SOURCE_GENERATE_IAM_ROLE,
36
+ SAVE_FILE_NAME,
37
+ FUNCTION_NAME
36
38
  }
37
39
  } = require("../../../../../MainLibs");
38
40
 
@@ -46,23 +48,23 @@ const templatePath = path.join(__dirname, "./template.ejs")
46
48
  * @return {{ templatePath, templateData, setting } }
47
49
  */
48
50
  function data(_izContext, flowSchema, srcPath) {
49
- const handler = HANDLER.hdrInv;
51
+ // const handler = HANDLER.hdrInv;
50
52
  const flowTag = flowSchema.flowTag;
51
- const functionName = flowTag + upperCase(handler);
52
- const action = SOURCE_GENERATE_IAM_ROLE.EventBridge;
53
- const fileName = `${upperCase(flowTag)}${upperCase(action)}_Main`;
53
+ // const functionName = "EventBridge" + upperCase(handler);
54
+ // const action = SOURCE_GENERATE_IAM_ROLE.EventBridge;
55
+ // const fileName = `${upperCase(flowTag)}${upperCase(action)}_Main`;
54
56
  return [{
55
57
  templatePath: templatePath,
56
58
  templateData: {
57
- functionName: functionName,
59
+ functionName: "EventBridge",
58
60
  flowTag: flowTag,
59
61
  roleName: SOURCE_GENERATE_IAM_ROLE.EventBridge,
60
- action: action,
62
+ // action: action,
61
63
  firstLetterUpperCase: upperCase,
62
64
  },
63
65
  setting: {
64
- savePath: path.join(srcPath, SOURCE_PATH.flowSchemaEventBridge),
65
- saveFileName: fileName,
66
+ savePath: path.join(srcPath, SOURCE_PATH.flowSchemaEventBridge, flowSchema.flowTag, "source/"),
67
+ saveFileName: "EventBridge_Main",
66
68
  fileExtension: '.js',
67
69
  isAppend: false
68
70
  }
@@ -78,9 +78,9 @@ module.exports.<%- functionName %>Main = async (
78
78
  _izContext.logger.debug('<%- functionName %> requestParams: ', requestParams);
79
79
  _izContext.logger.debug('<%- functionName %> callingFlowConfig: ', callingFlowConfig);
80
80
 
81
- //(<additionalParams>)
82
- //(</additionalParams>)
83
-
81
+ //(<eventBridgeHook>)
82
+ //(</eventBridgeHook>)
83
+
84
84
  } catch (err) {
85
85
  _izContext.logger.error('error <%- firstLetterUpperCase(functionName) %>Main: ', err)
86
86
  throw (err)
@@ -46,12 +46,9 @@ const {
46
46
 
47
47
  function data(_izContext, flowSchema, srcPath) {
48
48
  const flowStepSplitKey = Object.keys(flowSchema.flowSteps)[0].split("_");
49
- let queueName;
50
- let queueNameSubscription;
51
- if (Object.keys(flowSchema.flowSteps).length > 3) {
52
- queueName = flowStepSplitKey[3] + 'Out';
53
- queueNameSubscription = flowStepSplitKey[3]
54
- }
49
+ // console.log({ flowStepSplitKey })
50
+ let queueName = flowStepSplitKey[3] + 'Out';
51
+ let queueNameSubscription = flowStepSplitKey[3];
55
52
 
56
53
  return [{
57
54
  templatePath,
@@ -50,26 +50,24 @@ function data(_izContext, flowSchema, srcPath) {
50
50
  }
51
51
 
52
52
  function createSourceParams(_izContext, flowSchema, srcPath) {
53
- let functionName = upperCase(flowSchema.flowTag);
53
+ let functionName = upperCase(FUNCTION_NAME.flowSchemaExternalTopic);
54
54
  let handlerType = upperCase(HANDLER.hdrSqs);
55
55
  let externalTopicName = FUNCTION_NAME.flowSchemaExternalTopic + 'Out';
56
- let externalTopicShortName = 'ExtTopicOut';
57
- let functionConfig = upperCase(flowSchema.flowTag) + externalTopicShortName + upperCase(shortNameHandler(handlerType));
56
+ let functionConfig = "ExtTopicOut" + upperCase(shortNameHandler(handlerType));
58
57
  let additionalResourcePermission = defaultIamRolePerAction();
59
- const handler = HANDLER.hdrSqs; // Using hdrSqs as the default handler
60
- const action = flowSchema.flowTag || 'defaultAction'; // Using flowTag as the action name
61
- const event = resourceNames(RESOURCE_CLASSES.sqs, upperCase(action) + upperCase(handler));
58
+ // const action = flowSchema.flowTag || 'defaultAction'; // Using flowTag as the action name
59
+ // const event = resourceNames(RESOURCE_CLASSES.sqs, upperCase(action) + upperCase(handler));
62
60
 
63
61
  return {
64
62
  templatePath: templatePath,
65
63
  templateData: {
66
- resourceLocation: SOURCE_PATH.resourceLocationWebSocket,
67
- event,
64
+ resourceLocation: path.join(SOURCE_PATH.resourceLocationFlowSchemaExternalTopic, flowSchema.flowTag, "source/"),
68
65
  functionName,
69
66
  handlerType,
70
67
  functionNameConfig: functionConfig,
71
68
  roleName: SOURCE_GENERATE_IAM_ROLE.ExternalTopicRole,
72
- externalTopicName
69
+ externalTopicName,
70
+ additionalResourcePermission,
73
71
  },
74
72
  setting: {
75
73
  savePath: path.join(srcPath, SOURCE_PATH.appYaml),
@@ -1,10 +1,10 @@
1
1
  <%_ const join = require('path').join _%>
2
2
  <%- firstLetterUpperCase(functionNameConfig) %>:
3
- handler: <%- join(resourceLocation, functionName, `${firstLetterUpperCase(externalTopicName)}_${firstLetterUpperCase(handlerType)}.main`) %>
3
+ handler: <%- join(resourceLocation, `${firstLetterUpperCase(functionName)}_${firstLetterUpperCase(handlerType)}.main`) %>
4
4
  name: ${self:custom.iz_resourcePrefix}<%- firstLetterUpperCase(functionNameConfig) %>
5
5
  events:
6
6
  - sqs:
7
- arn: <%- event %>
7
+ arn: arn:aws:sqs:${self:custom.iz_region}:${self:custom.iz_accountId}:${self:custom.iz_resourcePrefix}<%- firstLetterUpperCase(functionName) %>
8
8
  batchSize: 10
9
9
  role: <%- firstLetterUpperCase(roleName) _%>Role
10
10
  #<#<%_ functionName _%><%_ handlerType _%>IamRole#>
@@ -20,7 +20,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
20
20
  const path = require('path');
21
21
  const { FLOW_SCHEMA_HOOK_STATE, HANDLER } = require('@izara_project/izara-core-library-service-schemas/src/Consts')
22
22
 
23
- const { SOURCE_PATH, FUNCTION_NAME } = require("../../../../../../MainLibs/src/Consts");
23
+ const { SOURCE_PATH, FUNCTION_NAME, SOURCE_GENERATE_IAM_ROLE } = require("../../../../../../MainLibs/src/Consts");
24
24
  const { firstLetterLowerCase: lowerCase, firstLetterUpperCase: upperCase } = require("../../../../../../MainLibs/src/Utils");
25
25
  const templatePath = path.join(__dirname, "template.ejs")
26
26
 
@@ -55,7 +55,7 @@ function createParamsForCreateSource(_izContext, flowSchema, srcPath) {
55
55
  firstLetterUpperCase: upperCase,
56
56
  },
57
57
  setting: {
58
- savePath: path.join(srcPath, SOURCE_PATH.flowSchemaExternalTopic, flowSchema.flowTag + '/'),
58
+ savePath: path.join(srcPath, SOURCE_PATH.flowSchemaExternalTopic, flowSchema.flowTag, 'source/'),
59
59
  saveFileName: `${functionName}Out_${handlerType}`,
60
60
  fileExtension: ".js",
61
61
  isAppend: false
@@ -51,7 +51,7 @@ function createParamsForCreateSource(_izContext, flowSchema, srcPath) {
51
51
  externalTopicOutMain: FUNCTION_NAME.flowSchemaExternalTopic + 'Out',
52
52
  },
53
53
  setting: {
54
- savePath: path.join(srcPath, SOURCE_PATH.flowSchemaExternalTopic, flowSchema.flowTag + '/'),
54
+ savePath: path.join(srcPath, SOURCE_PATH.flowSchemaExternalTopic, flowSchema.flowTag, 'source/'),
55
55
  saveFileName: `${functionName}Out_Main`,
56
56
  fileExtension: ".js",
57
57
  isAppend: false
@@ -51,25 +51,16 @@ function data(_izContext, flowSchema, srcPath) {
51
51
  }
52
52
 
53
53
  function createSourceParams(_izContext, flowSchema, srcPath) {
54
- let functionName = upperCase(flowSchema.flowTag);
54
+ // let functionName = upperCase(flowSchema.flowTag);
55
55
  let handlerType = upperCase("hdrWbs");
56
- let externalTopicName = FUNCTION_NAME.flowSchemaExternalTopic;
56
+ // let externalTopicName = FUNCTION_NAME.flowSchemaExternalTopic;
57
+ let functionName = FUNCTION_NAME.flowSchemaExternalTopic;
57
58
  let externalTopicShortName = 'ExtTopic';
58
- let functionConfig = upperCase(flowSchema.flowTag) + externalTopicShortName + upperCase(shortNameHandler(handlerType));
59
+ let functionConfig = externalTopicShortName + upperCase(shortNameHandler(handlerType));
59
60
  let additionalResourcePermission = defaultIamRolePerAction();
60
- let route = "webSocket";
61
+ let route = flowSchema.flowTag;
61
62
 
62
63
  additionalResourcePermission.push(
63
- createIamRole(
64
- {
65
- [RESOURCE_CLASSES.sns]: [
66
- SNS_RESOURCE.publish
67
- ]
68
- },
69
- [
70
- resourceNames(RESOURCE_CLASSES.sns, "InImportBatchMainCreate")
71
- ]
72
- ),
73
64
  createIamRole(
74
65
  {
75
66
  [RESOURCE_CLASSES.dynamoDbTable]: [
@@ -96,44 +87,18 @@ function createSourceParams(_izContext, flowSchema, srcPath) {
96
87
  )
97
88
  )
98
89
 
99
- if (flowSchema?.hook) {
100
- for (const [hookName, hookProperties] of Object.entries(flowSchema.hook)) {
101
- if (hookName === FLOW_SCHEMA_HOOK_STATE.beforeCreate) {
102
- for (const hookFunction of hookProperties.functionList) {
103
- if ((hookFunction.event.hasOwnProperty("initialEvent") && (hookFunction.event.initialEvent === true))) {
104
- if (hookFunction?.permission) {
105
- for (const permission of hookFunction.permission) {
106
- additionalResourcePermission.push(
107
- createIamRole(
108
- permission.action,
109
- permission.resource.map(resource =>
110
- externalResourceYaml(
111
- resource.resource,
112
- resource.resourceName,
113
- resource.serviceTag),
114
- permission.effect
115
- )
116
- )
117
- )
118
- }
119
- }
120
- }
121
- }
122
- }
123
- }
124
- }
125
- // console.log("additionalResourcePermission in createObjectS3", JSON.stringify(additionalResourcePermission))
90
+
126
91
  return {
127
92
  templatePath: templatePath,
128
93
  templateData: {
129
- resourceLocation: SOURCE_PATH.resourceLocationWebSocket,
94
+ resourceLocation: path.join(SOURCE_PATH.resourceLocationFlowSchemaExternalTopic, flowSchema.flowTag, "source/"),
130
95
  functionName,
131
96
  handlerType,
132
97
  functionNameConfig: functionConfig,
133
98
  additionalResourcePermission,
134
99
  route,
135
100
  roleName: SOURCE_GENERATE_IAM_ROLE.ExternalTopicRole,
136
- externalTopicName
101
+ // externalTopicName
137
102
  },
138
103
  setting: {
139
104
  savePath: path.join(srcPath, SOURCE_PATH.appYaml),
@@ -1,6 +1,6 @@
1
1
  <%_ const join = require('path').join; _%>
2
2
  <%- firstLetterUpperCase(functionNameConfig) %>:
3
- handler: <%- join(resourceLocation, functionName, `${firstLetterUpperCase(externalTopicName)}_${firstLetterUpperCase(handlerType)}.main`)%>
3
+ handler: <%- join(resourceLocation, `${firstLetterUpperCase(functionName)}_${firstLetterUpperCase(handlerType)}.main`)%>
4
4
  name: ${self:custom.iz_resourcePrefix}<%- firstLetterUpperCase(functionNameConfig) %>
5
5
  events:
6
6
  - websocket:
@@ -51,10 +51,10 @@ function createParamsForCreateSource(_izContext, flowSchema, srcPath) {
51
51
  isAsync,
52
52
  functionName: functionName,
53
53
  fileName: upperCase(functionName),
54
- flowTag
54
+ flowTag,
55
55
  },
56
56
  setting: {
57
- savePath: path.join(srcPath, SOURCE_PATH.flowSchemaExternalTopic, flowSchema.flowTag + '/'),
57
+ savePath: path.join(srcPath, SOURCE_PATH.flowSchemaExternalTopic, flowSchema.flowTag, 'source/'),
58
58
  saveFileName: `${upperCase(functionName)}_${handlerType}`,
59
59
  fileExtension: ".js",
60
60
  isAppend: false
@@ -50,6 +50,7 @@ module.exports.main = middlewareHandler.wrap(async (event, context, callback) =>
50
50
  {
51
51
  taskKey: correlationId,
52
52
  connectionId: connectionId,
53
+ originTimestamp: new Date.now()
53
54
  }
54
55
  )
55
56
 
@@ -23,6 +23,8 @@ const { SOURCE_PATH, FUNCTION_NAME } = require("../../../../../../MainLibs/src/C
23
23
  const { firstLetterLowerCase: lowerCase, firstLetterUpperCase: upperCase } = require("../../../../../../MainLibs/src/Utils");
24
24
  const templatePath = path.join(__dirname, "template.ejs");
25
25
  const getObjectSchema = require('@izara_project/izara-core-library-service-schemas/src/GetObjectSchema')
26
+ const statusFieldTemplate = path.join(__dirname, "../../../createRecordByStatusType/statusFieldTemplate.ejs")
27
+ const storedCacheTemplate = path.join(__dirname, "../../../createRecordByStatusType/storedCacheTemplate.ejs")
26
28
 
27
29
  /**
28
30
  * receive objectSchema
@@ -40,6 +42,7 @@ function data(_izContext, flowSchema, srcPath) {
40
42
  function createParamsForCreateSource(_izContext, flowSchema, srcPath) {
41
43
  const functionName = upperCase(FUNCTION_NAME.flowSchemaExternalTopic)
42
44
  const splitKey = Object.keys(flowSchema.flowSteps)[0].split('_')
45
+ // stockLocation_Test_flowStep_TopicName_In
43
46
  // let objectSchema = await getObjectSchema.getObjectSchemaCombineFieldNamesWithCache(_izContext, flowSchema.objType)
44
47
  // let fieldNames = Object.keys(objectSchema.fieldNames)
45
48
  return {
@@ -48,9 +51,12 @@ function createParamsForCreateSource(_izContext, flowSchema, srcPath) {
48
51
  serviceTag: splitKey[0],
49
52
  topicName: splitKey[3] + '_' + splitKey[4],
50
53
  externalTopicMain: FUNCTION_NAME.flowSchemaExternalTopic + 'Main',
54
+ storedCacheTemplate,
55
+ statusFieldTemplate,
56
+ statusType: flowSchema.statusType,
51
57
  },
52
58
  setting: {
53
- savePath: path.join(srcPath, SOURCE_PATH.flowSchemaExternalTopic, flowSchema.flowTag + '/'),
59
+ savePath: path.join(srcPath, SOURCE_PATH.flowSchemaExternalTopic, flowSchema.flowTag, 'source/'),
54
60
  saveFileName: `${functionName}_Main`,
55
61
  fileExtension: ".js",
56
62
  isAppend: false
@@ -35,6 +35,9 @@ const NoRetryError = require('@izara_project/izara-core-library-core').NoRetryEr
35
35
  const { v4: uuidv4 } = require('uuid')
36
36
  const coreConsts = require("@izara_project/izara-core-library-core/src/Consts");
37
37
  const { TOPIC_NAME_GENERATE_CODE } = require('@izara_project/izara-market-library-service-schemas/src/GenerateCodeLibs/src/Consts')
38
+ <% if (statusType === "statusField") { %>
39
+ const { createFieldNamesFromRequestParamsByObjectSchema } = require('@izara_project/izara-market-library-service-schemas/src/GenerateCodeLibs/src/GenerateCodeLibs')
40
+ <% } %>
38
41
  /**
39
42
  *
40
43
  *
@@ -59,13 +62,21 @@ module.exports.<%- externalTopicMain%> = async (
59
62
  ) => {
60
63
 
61
64
  try {
62
- // send message to ImportBatchCreateHdrSqs
63
- let sendMessageToCreateEndpoint = {
64
- Message: JSON.stringify(requestParams),
65
- TopicArn: await snsSharedLib.snsTopicArnByFlowSchema(_izContext, '<%- topicName%>', '<%- serviceTag%>')
66
- }
67
- _izContext.logger.debug("sendMessageToCreateEndpoint", sendMessageToCreateEndpoint);
68
- await sns.publishAsync(_izContext, sendMessageToCreateEndpoint);
65
+
66
+ <% if (statusType === "statusField") { %>
67
+ <%- include(statusFieldTemplate) %>
68
+ <% } else if (statusType === "storedCache") { %>
69
+ <%- include(storedCacheTemplate) %>
70
+
71
+ <% } %>
72
+
73
+ let sendMessageToCreateEndpoint = {
74
+ Message: JSON.stringify(messageObject),
75
+ TopicArn: await snsSharedLib.snsTopicArnByFlowSchema(_izContext, '<%- topicName %>', '<%- serviceTag%>')
76
+ }
77
+ _izContext.logger.debug("sendMessageToCreateEndpoint", sendMessageToCreateEndpoint);
78
+ await sns.publishAsync(_izContext, sendMessageToCreateEndpoint);
79
+
69
80
 
70
81
  } catch (err) {
71
82
  _izContext.logger.error('error WebSocketInvoke: ', err)
@@ -23,6 +23,7 @@ const { firstLetterLowerCase: lowerCase, firstLetterUpperCase: upperCase } = req
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
 
26
+
26
27
  /**
27
28
  * receive objectSchema
28
29
  * create data for WebScoket handler template
@@ -42,7 +43,8 @@ function createParamsForCreateSource(_izContext, flowSchema, srcPath) {
42
43
  return {
43
44
  templatePath: templatePath,
44
45
  templateData: {
45
- topicArn
46
+ topicArn,
47
+
46
48
  },
47
49
  setting: {
48
50
  savePath: path.join(srcPath, SOURCE_PATH.flowSchemaOwnTopic, flowSchema.flowTag, "source/"),