@izara_project/izara-market-library-service-schemas 1.0.40 → 1.0.42

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 (75) hide show
  1. package/package.json +1 -1
  2. package/src/MainLibs/src/Consts.js +1 -1
  3. package/src/reStructure/GenerateSchema.js +6 -6
  4. package/src/reStructure/TemplateData/EndpointPerService/mainFunction/create/template.ejs +20 -12
  5. package/src/reStructure/TemplateData/EndpointPerService/mainFunction/delete/template.ejs +23 -8
  6. package/src/reStructure/TemplateData/EndpointPerService/mainFunction/update/template.ejs +28 -21
  7. package/src/reStructure/TemplateData/externalService/snsTopicSubscriptions/data.js +0 -32
  8. package/src/reStructure/TemplateData/flowSchema/CreateRecordComplete/functionYaml/data.js +1 -1
  9. package/src/reStructure/TemplateData/flowSchema/components/upload/createObject/mainFunction/template.ejs +1 -1
  10. package/src/reStructure/TemplateData/flowSchema/components/websocket/connect/functionYaml/data.js +5 -2
  11. package/src/reStructure/TemplateData/flowSchema/components/websocket/connect/functionYaml/template.ejs +1 -1
  12. package/src/reStructure/TemplateData/flowSchema/dynamoDb/data.js +0 -20
  13. package/src/reStructure/TemplateData/flowSchema/eventBridge/functionYaml/data.js +7 -16
  14. package/src/reStructure/TemplateData/flowSchema/eventBridge/handler/inv/data.js +2 -2
  15. package/src/reStructure/TemplateData/flowSchema/eventBridge/handler/inv/template.ejs +0 -1
  16. package/src/reStructure/TemplateData/flowSchema/externalTopic/Complete/functionYaml/data.js +112 -0
  17. package/src/reStructure/TemplateData/flowSchema/externalTopic/Complete/handler/data.js +93 -0
  18. package/src/reStructure/TemplateData/flowSchema/externalTopic/Complete/mainFunction/data.js +61 -0
  19. package/src/reStructure/TemplateData/flowSchema/externalTopic/Complete/mainFunction/template.ejs +96 -0
  20. package/src/reStructure/TemplateData/flowSchema/externalTopic/{functionYaml → Process/functionYaml}/data.js +20 -4
  21. package/src/reStructure/TemplateData/flowSchema/externalTopic/{handler → Process/handler}/data.js +3 -3
  22. package/src/reStructure/TemplateData/flowSchema/externalTopic/Process/handler/template.ejs +87 -0
  23. package/src/reStructure/TemplateData/flowSchema/externalTopic/{mainFunction → Process/mainFunction}/data.js +2 -2
  24. package/src/reStructure/TemplateData/flowSchema/externalTopic/{mainFunction → Process/mainFunction}/template.ejs +2 -2
  25. package/src/reStructure/TemplateData/flowSchema/externalTopic/sns-in-sqs/data.js +14 -4
  26. package/src/reStructure/TemplateData/flowSchema/externalTopic/sns-in-sqs/sqsTemplate.ejs +52 -0
  27. package/src/reStructure/TemplateData/flowSchema/externalTopic/sns-out/data.js +1 -1
  28. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComplete/functionYaml/data.js +10 -9
  29. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComplete/functionYaml/template.ejs +1 -1
  30. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComplete/handler/data.js +8 -4
  31. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComplete/handler/template.ejs +1 -1
  32. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComplete/mainFunction/data.js +12 -11
  33. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComplete/mainFunction/template.ejs +93 -49
  34. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComponent/functionYaml/data.js +1 -1
  35. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComponent/handler/data.js +1 -1
  36. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComponent/handler/template.ejs +2 -0
  37. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComponent/mainFunction/data.js +3 -2
  38. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComponent/mainFunction/template.ejs +2 -2
  39. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaComponent/functionYaml/data.js +1 -1
  40. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaComponent/mainFunction/data.js +1 -1
  41. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaComponent/mainFunction/template.ejs +2 -2
  42. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/sns-in/data.js +9 -21
  43. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/sns-in/sqsTemplate.ejs +0 -10
  44. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/sns-out/data.js +1 -1
  45. package/src/reStructure/TemplateData/flowSchema/{flowSchemaOwnTopic/flowStep → flowStep}/functionYaml/data.js +37 -24
  46. package/src/reStructure/TemplateData/flowSchema/flowStep/functionYaml/template.ejs +20 -0
  47. package/src/reStructure/TemplateData/flowSchema/{flowSchemaOwnTopic/flowStep → flowStep}/handler/data.js +24 -20
  48. package/src/reStructure/TemplateData/flowSchema/{flowSchemaOwnTopic/flowStep → flowStep}/mainFunction/data.js +27 -22
  49. package/src/reStructure/TemplateData/flowSchema/flowStep/sns-in/data.js +90 -0
  50. package/src/reStructure/TemplateData/flowSchema/flowStep/sns-in/template.ejs +45 -0
  51. package/src/reStructure/TemplateData/flowSchema/generateTemplateData.js +45 -29
  52. package/src/reStructure/TemplateData/flowSchema/register/complete/functionYaml/data.js +3 -1
  53. package/src/reStructure/TemplateData/flowSchema/register/complete/handler/data.js +0 -1
  54. package/src/reStructure/TemplateData/flowSchema/register/complete/mainFunction/template.ejs +33 -29
  55. package/src/reStructure/TemplateData/flowSchema/register/dynamoDB/register.js +0 -17
  56. package/src/reStructure/TemplateData/flowSchema/register/sns-in/data.js +0 -1
  57. package/src/reStructure/TemplateData/flowSchema/register/subscriptionOutAll/data.js +1 -3
  58. package/src/reStructure/TemplateData/flowSchema/register/subscriptionOutAll/template.ejs +2 -2
  59. package/src/reStructure/TemplateData/flowSchema/register/wbs/functionYaml/data.js +0 -29
  60. package/src/reStructure/TemplateData/flowSchema/register/wbs/handler/data.js +0 -1
  61. package/src/reStructure/TemplateData/flowSchema/register/wbs/handler/template.ejs +3 -5
  62. package/src/reStructure/TemplateData/flowSchema/register/wbs/mainFunction/template.ejs +35 -32
  63. package/src/reStructure/TemplateData/flowSchema/templateBystatusType/triggerCacheTemplate.ejs +7 -1
  64. package/src/reStructure/TemplateData/flowSchema/webSocketComplete/functionYaml/data.js +1 -1
  65. package/src/reStructure/TemplateData/flowSchema/webSocketComplete/sqs/data.js +97 -0
  66. package/src/reStructure/TemplateData/flowSchema/webSocketComplete/sqs/template.ejs +52 -0
  67. package/src/reStructure/TemplateData/perActionComplete/create/mainFunction/template.ejs +1 -0
  68. package/src/reStructure/TemplateData/propertyValueSchema/generateTemplateData.js +18 -18
  69. package/src/reStructure/TemplateData/propertyValueSchema/objectPropertyValueSchema/data.js +82 -79
  70. package/src/reStructure/TemplateData/propertyValueSchema/relationshipPropertyValueSchema/data.js +33 -37
  71. /package/src/reStructure/TemplateData/flowSchema/externalTopic/{functionYaml → Complete/functionYaml}/template.ejs +0 -0
  72. /package/src/reStructure/TemplateData/flowSchema/externalTopic/{handler → Complete/handler}/template.ejs +0 -0
  73. /package/src/reStructure/TemplateData/flowSchema/{flowSchemaOwnTopic/flowStep → externalTopic/Process}/functionYaml/template.ejs +0 -0
  74. /package/src/reStructure/TemplateData/flowSchema/{flowSchemaOwnTopic/flowStep → flowStep}/handler/template.ejs +0 -0
  75. /package/src/reStructure/TemplateData/flowSchema/{flowSchemaOwnTopic/flowStep → flowStep}/mainFunction/template.ejs +0 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@izara_project/izara-market-library-service-schemas",
3
- "version": "1.0.40",
3
+ "version": "1.0.42",
4
4
  "description": "Schemas for Izara Market project",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -276,7 +276,7 @@ const FUNCTION_NAME = {
276
276
  flowSchemaOwnTopicEndpoint: "flowSchemaOwnTopicEndpoint",
277
277
  flowSchemaOwnTopicEndpointComplete: "flowSchemaOwnTopicEndpointComplete",
278
278
  flowSchemaExternalTopic: "externalTopic",
279
- flowSchemaEventBridge: "flowSchemaEventBridge",
279
+ flowSchemaEventBridge: "EventBridge",
280
280
  createRecordComplete: "createRecordComplete",
281
281
  flowSchemaRegister: "register",
282
282
  };
@@ -34,7 +34,7 @@ const { validatePathWithRootServicePath } = require("./libs/GenerateCodeLibs");
34
34
 
35
35
  async function generateSchema(_izContext, objSchemaPath, generateSchemaSettings) {
36
36
  try {
37
- console.log('objSchemaPath', objSchemaPath);
37
+ console.log('generateSchema', { objSchemaPath, generateSchemaSettings });
38
38
  // --------- Prepare path -------------
39
39
  // point to app/src
40
40
  let saveFilePath = join(objSchemaPath, `../`);
@@ -70,14 +70,14 @@ async function generateSchema(_izContext, objSchemaPath, generateSchemaSettings)
70
70
  for (const generateSetting of generateSchemaSettings) {
71
71
  console.log('Loading template:', generateSetting.generateName);
72
72
  console.log('Setting data:', generateSetting);
73
- console.log('schemaPath:', schemaConfig.TemplateAndData[generateSetting.generateName]);
74
- console.log('schemaPath:', join(__dirname, schemaConfig.TemplateAndData[generateSetting.generateName]));
73
+ // console.log('schemaPath:', schemaConfig.TemplateAndData[generateSetting.generateName]);
74
+ // console.log('schemaPath:', join(__dirname, schemaConfig.TemplateAndData[generateSetting.generateName]));
75
75
 
76
76
  // get generateSchema template depend on generateName
77
77
  let generateSchemaData = require(join(__dirname, schemaConfig.TemplateAndData[generateSetting.generateName]));
78
- console.log("generateSchemaData: ", generateSchemaData);
78
+ // console.log("generateSchemaData: ", generateSchemaData);
79
79
 
80
- let createSourceResult = await generateSchemaData(_izContext, objSchemaPath, generateSetting);
80
+ let createSourceResult = await generateSchemaData(_izContext, objSchemaPath, generateSchemaSettings);
81
81
 
82
82
  // Filter out empty or invalid objects before adding to allCreateSource
83
83
  if (Array.isArray(createSourceResult)) {
@@ -115,7 +115,7 @@ async function generateSchema(_izContext, objSchemaPath, generateSchemaSettings)
115
115
 
116
116
  // validate path before empty folder
117
117
  for (let emptyPath of allEmptyPath) {
118
- console.log("emptyPath: ", emptyPath);
118
+ // console.log("emptyPath: ", emptyPath);
119
119
  validatePathWithRootServicePath(localServicePath, emptyPath)
120
120
  }
121
121
 
@@ -84,15 +84,6 @@ module.exports.createMain = async (
84
84
 
85
85
  let errorsFound = [];
86
86
 
87
- const userId = _izContext.correlationIds.get(coreConsts.BASE_USER_ID);
88
- const targetId = _izContext.correlationIds.get(coreConsts.TARGET_ID)
89
- if (!userId) {
90
- errorsFound.push("Not have userId")
91
- }
92
-
93
- //(<beforeQuery>)
94
- //(</beforeQuery>)
95
-
96
87
  const objType = createObjType(requestParams.objectType);
97
88
 
98
89
  let objectSchema = await getObjectSchema.getObjSchemaS3WithHierarchy(
@@ -101,15 +92,32 @@ module.exports.createMain = async (
101
92
  );
102
93
  _izContext.logger.debug("objectSchema", objectSchema);
103
94
 
95
+ let userId;
96
+ let targetId;
97
+ if (objectSchema.generatedBy === "userGenerated") {
98
+ userId = _izContext.correlationIds.get(coreConsts.BASE_USER_ID);
99
+ targetId = _izContext.correlationIds.get(coreConsts.TARGET_ID)
100
+
101
+ if (!userId) {
102
+ errorsFound.push("Not have userId")
103
+ }
104
+
105
+ if (objectSchema.hasOwnProperty("belongTo") && !targetId) {
106
+ errorsFound.push('not have targetId')
107
+ }
108
+ }
109
+
110
+ //(<beforeQuery>)
111
+ //(</beforeQuery>)
112
+
113
+
104
114
  let objectSchemas = uploadUseCase.generateObjectSchemaForCombineFieldNames(
105
115
  _izContext,
106
116
  objectSchema
107
117
  );
108
118
  _izContext.logger.debug("objectSchemas", objectSchemas);
109
119
 
110
- if (objectSchema.hasOwnProperty("belongTo") && !targetId) {
111
- errorsFound.push('not have targetId')
112
- }
120
+
113
121
 
114
122
  let createDataDetails = await createDataDetailsLib(_izContext, objectSchemas);
115
123
  _izContext.logger.debug("createDataDetails is =", createDataDetails);
@@ -70,18 +70,33 @@ module.exports.deleteMain = async (
70
70
  callingFlowConfig: callingFlowConfig
71
71
  });
72
72
 
73
- let errorsFound = []
74
- const userId = _izContext.correlationIds.get(coreConsts.BASE_USER_ID);
75
- if (!userId) {
76
- errorsFound.push("not have userId");
73
+ let errorsFound = [];
74
+
75
+ const objType = createObjType(requestParams.objectType);
76
+
77
+ let objectSchema = await getObjectSchema.getObjSchemaS3WithHierarchy(
78
+ _izContext,
79
+ objType
80
+ );
81
+ _izContext.logger.debug("objectSchema", objectSchema);
82
+
83
+ let userId;
84
+ let targetId;
85
+ if (objectSchema.generatedBy === "userGenerated") {
86
+ userId = _izContext.correlationIds.get(coreConsts.BASE_USER_ID);
87
+ targetId = _izContext.correlationIds.get(coreConsts.TARGET_ID)
88
+
89
+ if (!userId) {
90
+ errorsFound.push("Not have userId")
91
+ }
92
+
93
+ if (objectSchema.hasOwnProperty("belongTo") && !targetId) {
94
+ errorsFound.push('not have targetId')
95
+ }
77
96
  }
78
97
 
79
98
  //(<beforeQuery>)
80
99
  //(</beforeQuery>)
81
- const objType = createObjType(requestParams.objectType);
82
- let objectSchema = await getObjectSchema.getObjSchemaS3WithCache(_izContext,
83
- objType)
84
- _izContext.logger.debug("objectSchema", objectSchema)
85
100
 
86
101
  /*
87
102
  create deleteDataDetail that decade what storage that have to access or not
@@ -71,12 +71,29 @@ module.exports.updateMain = async (
71
71
  callingFlowConfig
72
72
  });
73
73
 
74
- let errorFounds = [];
75
- const userId = _izContext.correlationIds.get(coreConsts.BASE_USER_ID);
76
- const targetId = _izContext.correlationIds.get(coreConsts.TARGET_ID);
74
+ let errorsFound = [];
77
75
 
78
- if (!userId) {
79
- errorFounds.push("Not have userId")
76
+ const objType = createObjType(requestParams.objectType);
77
+
78
+ let objectSchema = await getObjectSchema.getObjSchemaS3WithHierarchy(
79
+ _izContext,
80
+ objType
81
+ );
82
+ _izContext.logger.debug("objectSchema", objectSchema);
83
+
84
+ let userId;
85
+ let targetId;
86
+ if (objectSchema.generatedBy === "userGenerated") {
87
+ userId = _izContext.correlationIds.get(coreConsts.BASE_USER_ID);
88
+ targetId = _izContext.correlationIds.get(coreConsts.TARGET_ID)
89
+
90
+ if (!userId) {
91
+ errorsFound.push("Not have userId")
92
+ }
93
+
94
+ if (objectSchema.hasOwnProperty("belongTo") && !targetId) {
95
+ errorsFound.push('not have targetId')
96
+ }
80
97
  }
81
98
 
82
99
  //(<beforeQuery>)
@@ -91,16 +108,6 @@ module.exports.updateMain = async (
91
108
  fields: fields,
92
109
  versionedDataIds: versionedDataIds
93
110
  })
94
- const objType = createObjType(requestParams.objectType);
95
- let objectSchema = await getObjSchemaS3WithHierarchy(
96
- _izContext,
97
- objType
98
- )
99
- _izContext.logger.debug("objectSchema", objectSchema);
100
-
101
- if (objectSchema.hasOwnProperty("belongTo") && !targetId) {
102
- errorFounds.push('not have targetId')
103
- }
104
111
 
105
112
  let updateDataDetails = await createUpdateDataDetail(_izContext, objectSchema);
106
113
 
@@ -143,23 +150,23 @@ module.exports.updateMain = async (
143
150
  _izContext.logger.debug("missingVersionedDataIdLabels:: ", missingVersionedDataIdLabels);
144
151
 
145
152
  if (missingVersionedDataIdLabels.length) {
146
- errorFounds.push(`missing versionedDataIds of versionedDataLabel '${missingVersionedDataIdLabels.join(", ")}'`)
153
+ errorsFound.push(`missing versionedDataIds of versionedDataLabel '${missingVersionedDataIdLabels.join(", ")}'`)
147
154
  }
148
155
 
149
156
  // check missing update data of versionedDataLabels
150
157
  const missingDataVersionedDataLabels = versionedDataIdLabelKeys.filter(label => !versionedDataIdLabelKeys.includes(label))
151
158
  if (missingDataVersionedDataLabels.length) {
152
- errorFounds.push(`missing data of versionedDataLabels '${missingDataVersionedDataLabels.join(", ")}'`);
159
+ errorsFound.push(`missing data of versionedDataLabels '${missingDataVersionedDataLabels.join(", ")}'`);
153
160
  }
154
161
  // check mainNode Data should not exists
155
162
  if (Object.keys(updateMainNodeData).length) {
156
- errorFounds.push("cannot update mainNode if have versionedDataIds");
163
+ errorsFound.push("cannot update mainNode if have versionedDataIds");
157
164
  }
158
165
  }
159
166
 
160
167
  let messageAttributes
161
168
 
162
- if (errorFounds.length) {
169
+ if (errorsFound.length) {
163
170
  let updateNodeCompleteMessage = {
164
171
  objType: objType,
165
172
  objInstanceFull: {
@@ -168,7 +175,7 @@ module.exports.updateMain = async (
168
175
  },
169
176
  versionedDataIds: versionedDataIds,
170
177
  status: 'error',
171
- errorFounds: errorFounds
178
+ errorsFound: errorsFound
172
179
  };
173
180
 
174
181
 
@@ -345,7 +352,7 @@ module.exports.updateMain = async (
345
352
  versionedDataIds: versionedDataIds
346
353
  },
347
354
  status: "complete",
348
- errorFounds
355
+ errorsFound
349
356
  }
350
357
  } catch (err) {
351
358
  _izContext.logger.error('error AddressUpdate: ', err)
@@ -75,14 +75,6 @@ const createExternalSnsSubscriptions = async (_izContext, allObjSchemas, allRelS
75
75
  const snsServiceConfigForConfirmReserved = await snsSubscriptionConfirmReserved(_izContext);
76
76
  snsServiceConfigForConfirmReserved && snsServiceConfigArray.push(snsServiceConfigForConfirmReserved);
77
77
  }
78
- if (event.includes("extTopic")) {
79
- const snsServiceConfigForExtTopic = await snsSubscriptionFlowSchemaExternalTopic(_izContext, localFlowSchema);
80
- snsServiceConfigForExtTopic && snsServiceConfigArray.push(snsServiceConfigForExtTopic);
81
- }
82
- if (!localFlowSchema.statusType === "none") {
83
- const snsServiceConfigForCreateRecordByStatusType = await createFlowSchemaRegisterSnsTopicSubscriptions(_izContext, localFlowSchema);
84
- snsServiceConfigForCreateRecordByStatusType && snsServiceConfigArray.push(snsServiceConfigForCreateRecordByStatusType);
85
- }
86
78
  }
87
79
  }
88
80
  }
@@ -184,28 +176,4 @@ function snsSubscriptionConfirmReserved(_izContext) {
184
176
  }
185
177
  }
186
178
 
187
- function snsSubscriptionFlowSchemaExternalTopic(_izContext, localFlowSchema) {
188
- const flowStepOut = Object.keys(localFlowSchema.flowSteps)[1]
189
- const splitFlowStepOutKey = flowStepOut.split("_");
190
- const queueNameExtTopic = upperCase(FUNCTION_NAME.flowSchemaExternalTopic)
191
-
192
- return {
193
- serviceTag: [splitFlowStepOutKey[0]],
194
- topicName: splitFlowStepOutKey[2] + '_' + splitFlowStepOutKey[3],
195
- sqsEndpoint: queueNameExtTopic
196
- };
197
- }
198
-
199
- function createFlowSchemaRegisterSnsTopicSubscriptions(_izContext, localFlowSchema) {
200
- const flowStepKeys = Object.keys(localFlowSchema.flowSteps)[1];
201
- const flowStepKeySplit = flowStepKeys.split("_");
202
- const registerCompleteSqs = upperCase(FUNCTION_NAME.flowSchemaRegister);
203
-
204
- return {
205
- serviceTag: [flowStepKeySplit[0]],
206
- topicName: flowStepKeySplit[2],
207
- sqsEndpoint: registerCompleteSqs,
208
- }
209
- }
210
-
211
179
  module.exports = createExternalSnsSubscriptions;
@@ -99,7 +99,7 @@ function createSourceParams(_izContext, flowSchema, srcPath) {
99
99
  // )
100
100
  // )
101
101
  // }
102
- console.log({ additionalResourcePermission: JSON.stringify(additionalResourcePermission, null, 2) })
102
+ // console.log({ additionalResourcePermission: JSON.stringify(additionalResourcePermission, null, 2) })
103
103
 
104
104
  return {
105
105
  templatePath: templatePath,
@@ -69,7 +69,7 @@ module.exports.createObject = async (
69
69
  _izContext.correlationIds.set(coreConsts.TARGET_ID, "BasDevTarget");
70
70
 
71
71
  let flowSchema = await getObjectSchema.getFlowSchemaS3WithCache(_izContext, {
72
- flowTag: requestParams.flowTag,
72
+ flowTag: "<%- flowTag %>",
73
73
  serviceTag: process.env.iz_serviceTag
74
74
  // serviceTag: "GenerateCodeTamplateBas002"
75
75
  })
@@ -46,7 +46,10 @@ function createWebSocketConnectYaml(_izContext, srcPath) {
46
46
  {
47
47
  [RESOURCE_CLASSES.dynamoDbTable]: [
48
48
  DYNAMO_RESOURCE.putItem,
49
- DYNAMO_RESOURCE.deleteItem
49
+ DYNAMO_RESOURCE.getItem,
50
+ DYNAMO_RESOURCE.query,
51
+ DYNAMO_RESOURCE.deleteItem,
52
+ DYNAMO_RESOURCE.updateItem
50
53
  ]
51
54
  },
52
55
  [
@@ -71,7 +74,7 @@ function createWebSocketConnectYaml(_izContext, srcPath) {
71
74
  functionName,
72
75
  resourceLocation: SOURCE_PATH.resourceLocationWebSocketMain,
73
76
  additionalResourcePermission,
74
- roleName: "WebsocketMain"
77
+ roleName: "WebSocketMain"
75
78
 
76
79
  },
77
80
  setting: {
@@ -9,7 +9,7 @@
9
9
  route: $disconnect
10
10
  - websocket:
11
11
  route: $default
12
- role: WebsocketConnectRole
12
+ role: <%- roleName %>Role
13
13
  #<#<WebSocketConnectIamRole#>
14
14
  #<#/<WebSocketConnectIamRole#>
15
15
 
@@ -80,32 +80,12 @@ const createAwaitingMultipleStepDynamoDbData = (_izContext, flowSchema, allLocal
80
80
  AttributeType: "S"
81
81
  }));
82
82
 
83
- let additionalResourcePermission = defaultIamRolePerAction();
84
- additionalResourcePermission.push(
85
- createIamRole(
86
- {
87
- [RESOURCE_CLASSES.dynamoDbTable]: [
88
- DYNAMO_RESOURCE.putItem,
89
- DYNAMO_RESOURCE.getItem,
90
- DYNAMO_RESOURCE.query,
91
- DYNAMO_RESOURCE.deleteItem,
92
- DYNAMO_RESOURCE.updateItem
93
- ]
94
- },
95
- [
96
- resourceNames(RESOURCE_CLASSES.dynamoDbTable, tableName)
97
- ]
98
- )
99
- );
100
-
101
83
  return [{
102
84
  templatePath,
103
85
  templateData: {
104
86
  tableName,
105
87
  resourceName: tableName,
106
88
  attributes,
107
- additionalResourcePermission,
108
- roleName: SOURCE_GENERATE_IAM_ROLE.RegisterRole,
109
89
  },
110
90
  setting: {
111
91
  initialData: 'Resources:\n',
@@ -67,7 +67,9 @@ function createSourceParams(_izContext, flowSchema, srcPath) {
67
67
  return;
68
68
  }
69
69
 
70
- // Validate each schedule in the array
70
+
71
+
72
+ // Validate rate format for each schedule and Validate each schedule in the array
71
73
  for (const schedule of schedules) {
72
74
  if (!schedule.name || schedule.name.length === 0) {
73
75
  console.error("A schedule's name is not defined");
@@ -81,10 +83,7 @@ function createSourceParams(_izContext, flowSchema, srcPath) {
81
83
  console.error("A schedule's input is not defined");
82
84
  return;
83
85
  }
84
- }
85
86
 
86
- // Validate rate format for each schedule
87
- for (const schedule of schedules) {
88
87
  if (Array.isArray(schedule.rate) && schedule.rate.length <= 1) {
89
88
  const rate = schedule.rate[0];
90
89
 
@@ -113,9 +112,12 @@ function createSourceParams(_izContext, flowSchema, srcPath) {
113
112
  console.error(`Invalid rate expression: ${rate} - must start with 'rate' or 'cron'`);
114
113
  return;
115
114
  }
115
+ // add input for trigger event source
116
+ Object.assign(schedule.input, {
117
+ eventType: "eventBridgeSchedule"
118
+ })
116
119
  }
117
120
 
118
-
119
121
  let additionalResourcePermission = defaultIamRolePerAction();
120
122
  additionalResourcePermission.push(
121
123
  createIamRole(
@@ -132,16 +134,6 @@ function createSourceParams(_izContext, flowSchema, srcPath) {
132
134
  resourceNames(RESOURCE_CLASSES.dynamoDbTable, "WebSocketTask")
133
135
  ]
134
136
  ),
135
- createIamRole(
136
- {
137
- "execute-api": [
138
- "ManageConnections"
139
- ]
140
- },
141
- [
142
- resourceNames(RESOURCE_CLASSES.webSocket)
143
- ]
144
- )
145
137
  )
146
138
 
147
139
  // console.log("additionalResourcePermission in createObjectS3", JSON.stringify(additionalResourcePermission))
@@ -150,7 +142,6 @@ function createSourceParams(_izContext, flowSchema, srcPath) {
150
142
  templateData: {
151
143
  resourceLocation: path.join(SOURCE_PATH.resourceLocationFlowSchemaEventBridge, flowSchema.flowTag, "source/"),
152
144
  functionName,
153
- // action,
154
145
  functionNameConfig: functionNameConfig,
155
146
  additionalResourcePermission,
156
147
  roleName: SOURCE_GENERATE_IAM_ROLE.EventBridge,
@@ -52,7 +52,7 @@ function data(_izContext, flowSchema, srcPath) {
52
52
  const handler = HANDLER.hdrInv;
53
53
  const flowTag = flowSchema.flowTag;
54
54
  // const action = SOURCE_GENERATE_IAM_ROLE.EventBridge;
55
- const functionName = "EventBridge" + upperCase(handler);
55
+ const functionName = "EventBridge"
56
56
  // const fileName = `${upperCase(flowTag)}${upperCase(action)}_${upperCase(handler)}`;
57
57
  return [{
58
58
  templatePath: templatePath,
@@ -66,7 +66,7 @@ function data(_izContext, flowSchema, srcPath) {
66
66
  },
67
67
  setting: {
68
68
  savePath: path.join(srcPath, SOURCE_PATH.flowSchemaEventBridge, flowSchema.flowTag, "source/"),
69
- saveFileName: `EventBridge_${upperCase(handler)}`,
69
+ saveFileName: `${upperCase(functionName)}_${upperCase(handler)}`,
70
70
  fileExtension: '.js',
71
71
  isAppend: false
72
72
  }
@@ -19,7 +19,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
19
19
 
20
20
  const { middlewareHandler } = require("@izara_project/izara-middleware");
21
21
  const callingFlowSharedLib = require('@izara_project/izara-core-library-calling-flow');
22
- validateSchemaMiddleware
23
22
  const {
24
23
  validateSchemaMiddleware
25
24
  } = require('@izara_project/izara-market-library-service-schemas/src/GenerateCodeLibs/src/GenerateCodeLibs');
@@ -0,0 +1,112 @@
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
+ * create data for WebScoket handler template
46
+ *
47
+ * @param {Object} objectSchema
48
+ * @return {{templatePath, templateData,setting}}
49
+ */
50
+
51
+ function data(_izContext, flowSchema, srcPath) {
52
+ if (!flowSchema.outputTopic) {
53
+ return []
54
+ } else {
55
+ return [createSourceParams(_izContext, flowSchema, srcPath)]
56
+ }
57
+ }
58
+
59
+ function createSourceParams(_izContext, flowSchema, srcPath) {
60
+ let functionName = upperCase(flowSchema.flowTag) + "Complete"
61
+ let handlerType = upperCase(HANDLER.hdrSqs)
62
+ let additionalResourcePermission = defaultIamRolePerAction();
63
+ let queueName = functionName + handlerType;
64
+ let topicOut = upperCase(flowSchema.flowTag) + "_Out";
65
+ additionalResourcePermission.push(
66
+ createIamRole(
67
+ {
68
+ [RESOURCE_CLASSES.sqs]: Object.values(SQS_RESOURCE)
69
+ },
70
+ [
71
+ resourceNames(RESOURCE_CLASSES.sqs, queueName),
72
+ resourceNames(RESOURCE_CLASSES.sqs, queueName + "DLQ")
73
+ ]
74
+ )
75
+ )
76
+
77
+ if (Object.keys(flowSchema.flowSteps).includes("Out")) {
78
+ additionalResourcePermission.push(
79
+ createIamRole(
80
+ {
81
+ [RESOURCE_CLASSES.sns]: [
82
+ SNS_RESOURCE.publish
83
+ ]
84
+ },
85
+ [
86
+ resourceNames(RESOURCE_CLASSES.sns, topicOut)
87
+ ]
88
+ )
89
+ )
90
+ }
91
+
92
+ return {
93
+ templatePath: templatePath,
94
+ templateData: {
95
+ resourceLocation: path.join(SOURCE_PATH.resourceLocationFlowSchema, flowSchema.flowTag, "source/"),
96
+ functionName,
97
+ handlerType,
98
+ additionalResourcePermission,
99
+ functionNameConfig: upperCase(functionName) + upperCase(shortNameHandler(handlerType)),
100
+ roleName: SOURCE_GENERATE_IAM_ROLE.ExternalTopicRole,
101
+ queueName
102
+ },
103
+ setting: {
104
+ savePath: path.join(srcPath, SOURCE_PATH.appYaml),
105
+ saveFileName: upperCase(SAVE_FILE_NAME.flowSchema),
106
+ fileExtension: ".yml",
107
+ isAppend: true
108
+ }
109
+ }
110
+ }
111
+
112
+ module.exports = data;
@@ -0,0 +1,93 @@
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
+ * create data for WebScoket handler template
46
+ *
47
+ * @param {Object} objectSchema
48
+ * @return {{templatePath, templateData,setting}}
49
+ */
50
+
51
+ function data(_izContext, flowSchema, srcPath) {
52
+ if (!flowSchema.outputTopic) {
53
+ return []
54
+ } else {
55
+ return [createSourceParams(_izContext, flowSchema, srcPath)]
56
+ }
57
+ }
58
+
59
+ function createSourceParams(_izContext, flowSchema, srcPath) {
60
+ let functionName = upperCase(flowSchema.flowTag) + "Complete"
61
+ let handlerType = upperCase(HANDLER.hdrSqs)
62
+ let additionalResourcePermission = defaultIamRolePerAction();
63
+ let queueName = functionName + handlerType;
64
+
65
+ additionalResourcePermission.push(
66
+ createIamRole(
67
+ {
68
+ [RESOURCE_CLASSES.sqs]: Object.values(SQS_RESOURCE)
69
+ },
70
+ [
71
+ resourceNames(RESOURCE_CLASSES.sqs, queueName),
72
+ resourceNames(RESOURCE_CLASSES.sqs, queueName + "DLQ")
73
+ ]
74
+ )
75
+ )
76
+
77
+ return {
78
+ templatePath: templatePath,
79
+ templateData: {
80
+ functionName,
81
+ handlerType,
82
+ queueName
83
+ },
84
+ setting: {
85
+ savePath: path.join(srcPath, SOURCE_PATH.flowSchema, flowSchema.flowTag, "source/"),
86
+ saveFileName: `${functionName}_${handlerType}`,
87
+ fileExtension: ".js",
88
+ isAppend: false
89
+ }
90
+ }
91
+ }
92
+
93
+ module.exports = data;