@izara_project/izara-market-library-service-schemas 1.0.41 → 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 (88) 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/CreateRecordComplete/functionYaml/template.ejs +1 -0
  10. package/src/reStructure/TemplateData/flowSchema/components/upload/confirmReserved/functionYaml/template.ejs +1 -0
  11. package/src/reStructure/TemplateData/flowSchema/components/upload/createObject/mainFunction/template.ejs +1 -1
  12. package/src/reStructure/TemplateData/flowSchema/components/upload/createObjectComplete/functionYaml/template.ejs +1 -0
  13. package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/createPresignUrl/functionYaml/template.ejs +1 -0
  14. package/src/reStructure/TemplateData/flowSchema/components/websocket/connect/functionYaml/data.js +5 -2
  15. package/src/reStructure/TemplateData/flowSchema/dynamoDb/data.js +0 -20
  16. package/src/reStructure/TemplateData/flowSchema/eventBridge/functionYaml/data.js +7 -16
  17. package/src/reStructure/TemplateData/flowSchema/eventBridge/handler/inv/data.js +2 -2
  18. package/src/reStructure/TemplateData/flowSchema/eventBridge/handler/inv/template.ejs +0 -1
  19. package/src/reStructure/TemplateData/flowSchema/externalTopic/Complete/functionYaml/data.js +112 -0
  20. package/src/reStructure/TemplateData/flowSchema/externalTopic/{functionYaml → Complete/functionYaml}/template.ejs +1 -0
  21. package/src/reStructure/TemplateData/flowSchema/externalTopic/Complete/handler/data.js +93 -0
  22. package/src/reStructure/TemplateData/flowSchema/externalTopic/Complete/mainFunction/data.js +61 -0
  23. package/src/reStructure/TemplateData/flowSchema/externalTopic/Complete/mainFunction/template.ejs +96 -0
  24. package/src/reStructure/TemplateData/flowSchema/externalTopic/{functionYaml → Process/functionYaml}/data.js +20 -4
  25. package/src/reStructure/TemplateData/flowSchema/{flowSchemaOwnTopic/flowStep → externalTopic/Process}/functionYaml/template.ejs +1 -0
  26. package/src/reStructure/TemplateData/flowSchema/externalTopic/{handler → Process/handler}/data.js +3 -3
  27. package/src/reStructure/TemplateData/flowSchema/externalTopic/Process/handler/template.ejs +87 -0
  28. package/src/reStructure/TemplateData/flowSchema/externalTopic/{mainFunction → Process/mainFunction}/data.js +2 -2
  29. package/src/reStructure/TemplateData/flowSchema/externalTopic/{mainFunction → Process/mainFunction}/template.ejs +2 -2
  30. package/src/reStructure/TemplateData/flowSchema/externalTopic/sns-in-sqs/data.js +14 -4
  31. package/src/reStructure/TemplateData/flowSchema/externalTopic/sns-in-sqs/sqsTemplate.ejs +52 -0
  32. package/src/reStructure/TemplateData/flowSchema/externalTopic/sns-out/data.js +1 -1
  33. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComplete/functionYaml/data.js +4 -4
  34. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComplete/functionYaml/template.ejs +1 -0
  35. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComplete/handler/data.js +1 -2
  36. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComplete/handler/template.ejs +1 -1
  37. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComplete/mainFunction/data.js +5 -5
  38. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComplete/mainFunction/template.ejs +5 -2
  39. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComponent/functionYaml/data.js +1 -1
  40. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComponent/functionYaml/template.ejs +1 -0
  41. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComponent/handler/data.js +1 -1
  42. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComponent/handler/template.ejs +2 -0
  43. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComponent/mainFunction/data.js +3 -2
  44. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComponent/mainFunction/template.ejs +2 -2
  45. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaComponent/functionYaml/data.js +1 -1
  46. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaComponent/mainFunction/data.js +1 -1
  47. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaComponent/mainFunction/template.ejs +2 -2
  48. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/sns-in/data.js +9 -21
  49. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/sns-in/sqsTemplate.ejs +0 -10
  50. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/sns-out/data.js +1 -1
  51. package/src/reStructure/TemplateData/flowSchema/{flowSchemaOwnTopic/flowStep → flowStep}/functionYaml/data.js +36 -23
  52. package/src/reStructure/TemplateData/flowSchema/flowStep/functionYaml/template.ejs +20 -0
  53. package/src/reStructure/TemplateData/flowSchema/{flowSchemaOwnTopic/flowStep → flowStep}/handler/data.js +22 -18
  54. package/src/reStructure/TemplateData/flowSchema/{flowSchemaOwnTopic/flowStep → flowStep}/mainFunction/data.js +22 -18
  55. package/src/reStructure/TemplateData/flowSchema/flowStep/sns-in/data.js +90 -0
  56. package/src/reStructure/TemplateData/flowSchema/flowStep/sns-in/template.ejs +45 -0
  57. package/src/reStructure/TemplateData/flowSchema/generateTemplateData.js +41 -25
  58. package/src/reStructure/TemplateData/flowSchema/register/complete/functionYaml/data.js +1 -0
  59. package/src/reStructure/TemplateData/flowSchema/register/complete/functionYaml/template.ejs +1 -0
  60. package/src/reStructure/TemplateData/flowSchema/register/complete/handler/data.js +0 -1
  61. package/src/reStructure/TemplateData/flowSchema/register/complete/mainFunction/template.ejs +16 -17
  62. package/src/reStructure/TemplateData/flowSchema/register/dynamoDB/register.js +0 -17
  63. package/src/reStructure/TemplateData/flowSchema/register/sns-in/data.js +0 -1
  64. package/src/reStructure/TemplateData/flowSchema/register/subscriptionOutAll/data.js +1 -3
  65. package/src/reStructure/TemplateData/flowSchema/register/subscriptionOutAll/template.ejs +2 -2
  66. package/src/reStructure/TemplateData/flowSchema/register/wbs/functionYaml/data.js +0 -29
  67. package/src/reStructure/TemplateData/flowSchema/register/wbs/handler/data.js +0 -1
  68. package/src/reStructure/TemplateData/flowSchema/register/wbs/handler/template.ejs +0 -5
  69. package/src/reStructure/TemplateData/flowSchema/register/wbs/mainFunction/template.ejs +16 -15
  70. package/src/reStructure/TemplateData/flowSchema/templateBystatusType/triggerCacheTemplate.ejs +7 -1
  71. package/src/reStructure/TemplateData/flowSchema/webSocketComplete/functionYaml/data.js +1 -1
  72. package/src/reStructure/TemplateData/flowSchema/webSocketComplete/functionYaml/template.ejs +2 -1
  73. package/src/reStructure/TemplateData/flowSchema/webSocketComplete/sqs/data.js +97 -0
  74. package/src/reStructure/TemplateData/flowSchema/webSocketComplete/sqs/template.ejs +52 -0
  75. package/src/reStructure/TemplateData/perActionComplete/create/yaml/template.ejs +1 -0
  76. package/src/reStructure/TemplateData/perActionComplete/delete/yaml/template.ejs +1 -0
  77. package/src/reStructure/TemplateData/perActionComplete/get/yaml/template.ejs +1 -0
  78. package/src/reStructure/TemplateData/perActionComplete/update/yaml/template.ejs +1 -0
  79. package/src/reStructure/TemplateData/propertyValueSchema/generateTemplateData.js +18 -18
  80. package/src/reStructure/TemplateData/propertyValueSchema/objectPropertyValueSchema/data.js +82 -79
  81. package/src/reStructure/TemplateData/propertyValueSchema/relationshipPropertyValueSchema/data.js +33 -37
  82. package/src/reStructure/TemplateData/relationshipPerAction/create/complete/functionYaml/template.ejs +1 -0
  83. package/src/reStructure/TemplateData/relationshipPerAction/delete/complete/functionYaml/template.ejs +1 -0
  84. package/src/reStructure/TemplateData/relationshipPerAction/get/complete/functionYaml/template.ejs +1 -0
  85. package/src/reStructure/TemplateData/relationshipPerAction/update/complete/functionYaml/template.ejs +1 -0
  86. /package/src/reStructure/TemplateData/flowSchema/externalTopic/{handler → Complete/handler}/template.ejs +0 -0
  87. /package/src/reStructure/TemplateData/flowSchema/{flowSchemaOwnTopic/flowStep → flowStep}/handler/template.ejs +0 -0
  88. /package/src/reStructure/TemplateData/flowSchema/{flowSchemaOwnTopic/flowStep → flowStep}/mainFunction/template.ejs +0 -0
@@ -71,9 +71,12 @@ const createConfirmAfterUploadS3MainFunction = require('./components/upload/conf
71
71
  const createConfirmAfterUploadS3Queue = require('./components/upload/confirmReserved/queue/data');
72
72
 
73
73
  // flowSchema ExternalTopic components //
74
- const createExternalSqsFunctionYaml = require('./externalTopic/functionYaml/data');
75
- const createExternalSqsHandler = require('./externalTopic/handler/data');
76
- const createExternalSqsMainFunction = require('./externalTopic/mainFunction/data');
74
+ const createExternalSqsFunctionYaml = require('./externalTopic/Process/functionYaml/data');
75
+ const createExternalSqsHandler = require('./externalTopic/Process/handler/data');
76
+ const createExternalSqsMainFunction = require('./externalTopic/Process/mainFunction/data');
77
+ const createExternalSqsCompleteFunctionYaml = require("./externalTopic/Complete/functionYaml/data");
78
+ const createExternalSqsCompleteHandler = require("./externalTopic/Complete/handler/data");
79
+ const createExternalSqsCompleteMainFunction = require("./externalTopic/Complete/mainFunction/data");
77
80
  const createExternalTopicSnsInSqs = require('./externalTopic/sns-in-sqs/data');
78
81
  const createExternalTopicSnsOut = require('./externalTopic/sns-out/data')
79
82
 
@@ -83,19 +86,21 @@ const createFlowSchemaOwnTopicHandler = require('./flowSchemaOwnTopic/FlowSchema
83
86
  const createFlowSchemaOwnTopicMainFunction = require('./flowSchemaOwnTopic/FlowSchemaComponent/mainFunction/data');
84
87
 
85
88
  // flowSchema OwnTopicComplete component
86
- const createFlowSchemaOwnTopicCompleteFunctionYaml = require("./webSocketComplete/functionYaml/data");
87
- const createFlowSchemaOwnTopicCompleteHandler = require("./webSocketComplete/handler/data");
88
- const createFlowSchemaOwnTopicCompleteMainFunction = require("./webSocketComplete/mainFunction/data");
89
-
89
+ const createWebSocketCompleteMainFunctionYaml = require("./webSocketComplete/functionYaml/data");
90
+ const createWebSocketCompleteMainHandler = require("./webSocketComplete/handler/data");
91
+ const createWebSocketCompleteMainMainFunction = require("./webSocketComplete/mainFunction/data");
92
+ const createWebSocketCompleteMainSqs = require('./webSocketComplete/sqs/data');
90
93
  // flowSchema OwnTopicEndpoint component
94
+
91
95
  const createFlowSchemaOwnTopicEndpointFuntionYaml = require('./flowSchemaOwnTopic/EndpointComponent/functionYaml/data');
92
96
  const createFlowSchemaOwnTopicEndpointHandler = require('./flowSchemaOwnTopic/EndpointComponent/handler/data');
93
97
  const createFlowSchemaOwnTopicEndpointMainFunction = require('./flowSchemaOwnTopic/EndpointComponent/mainFunction/data');
94
98
 
95
99
  // flowSchema OnwTopic flowStep component
96
- const createFlowScheamOwnTopicFlowStepFunctionYml = require('./flowSchemaOwnTopic/flowStep/functionYaml/data');
97
- const createFlowSchemaOwnTopicFlowStepHandler = require('./flowSchemaOwnTopic/flowStep/handler/data');
98
- const createFlowScheamOwnTopicFlowStepMainFunction = require('./flowSchemaOwnTopic/flowStep/mainFunction/data')
100
+ const createFlowSchemaFlowStepFunctionYaml = require('./flowStep/functionYaml/data');
101
+ const createFlowSchemaFlowStepHandler = require('./flowStep/handler/data');
102
+ const createFlowSchemaFlowStepMainFunction = require('./flowStep/mainFunction/data')
103
+ const createFlowSchemaFlowStepSnsIn = require('./flowStep/sns-in/data');
99
104
  // flowSchema OwnTopicEndpointComplete component
100
105
  const createFlowSchemaOwnTopicEndpointCompleteFuntionYaml = require('./flowSchemaOwnTopic/EndpointComplete/functionYaml/data');
101
106
  const createFlowSchemaOwnTopicEndpointCompleteHandler = require('./flowSchemaOwnTopic/EndpointComplete/handler/data');
@@ -132,10 +137,10 @@ const createFlowSchemaRegisterDynamoDb = require('./register/dynamoDB/register')
132
137
  * @returns {Array} Array of generated code parameters
133
138
  */
134
139
  async function generateCodeWithTemplate(_izContext, objSchemaPath) {
135
- console.log("objSchemaPath in flowSchema generateTemplateAndData", objSchemaPath);
140
+ // console.log("objSchemaPath in flowSchema generateTemplateAndData", objSchemaPath);
136
141
  try {
137
142
  const saveFilePath = join(objSchemaPath, '../');
138
- console.log("saveFilePath in flowSchema generateTemplateAndData", saveFilePath)
143
+ // console.log("saveFilePath in flowSchema generateTemplateAndData", saveFilePath)
139
144
  let createSourceParams = [];
140
145
  const allLocalFlowSchemas = await getAllLocalFlowSchemas(_izContext, objSchemaPath);
141
146
  const allLocalObjectSchemas = await getAllLocalObjectSchemasWithHierarchy(_izContext, objSchemaPath);
@@ -146,24 +151,26 @@ async function generateCodeWithTemplate(_izContext, objSchemaPath) {
146
151
  const webSocketConnectHandler = createWebSocketConnectHandler(_izContext, saveFilePath);
147
152
 
148
153
  // flowSchema OwnTopic Complete component
149
- const flowSchemaOwnTopicCompleteFunctionYaml = createFlowSchemaOwnTopicCompleteFunctionYaml(_izContext, allLocalFlowSchemas, saveFilePath);
150
- const flowSchemaOwnTopicCompleteHandler = createFlowSchemaOwnTopicCompleteHandler(_izContext, saveFilePath);
151
- const flowSchemaOwnTopicCompleteMainFunction = createFlowSchemaOwnTopicCompleteMainFunction(_izContext, saveFilePath);
152
- const flowSchemaOwnTopicCompleteComponent = [...flowSchemaOwnTopicCompleteFunctionYaml, ...flowSchemaOwnTopicCompleteHandler, ...flowSchemaOwnTopicCompleteMainFunction]
154
+ const webSocketCompleteFunctionYaml = createWebSocketCompleteMainFunctionYaml(_izContext, allLocalFlowSchemas, saveFilePath);
155
+ const webSocketCompleteHandler = createWebSocketCompleteMainHandler(_izContext, saveFilePath);
156
+ const webSocketCompleteMainFunction = createWebSocketCompleteMainMainFunction(_izContext, saveFilePath);
157
+ const webSocketCompleteSqs = createWebSocketCompleteMainSqs(_izContext, allLocalFlowSchemas, saveFilePath)
158
+ const webSocketCompleteComponent = [...webSocketCompleteFunctionYaml, ...webSocketCompleteHandler, ...webSocketCompleteMainFunction, ...webSocketCompleteSqs]
153
159
 
154
160
  const webSocketResource = [...webSocketTaskTable, ...webSocketConnectYaml, ...webSocketConnectHandler]
155
161
  if (allLocalFlowSchemas.records.length) {
156
162
  createSourceParams.push(
157
163
  ...webSocketResource,
158
- ...flowSchemaOwnTopicCompleteComponent
164
+ ...webSocketCompleteComponent
159
165
  )
160
166
  }
161
167
 
168
+
162
169
  // get flowsteps out form all local object schemas
163
170
 
164
171
 
165
172
  for (const flowSchema of allLocalFlowSchemas.records) {
166
- console.log("flowSchema in Generate TemplateData", flowSchema);
173
+ // console.log("flowSchema in Generate TemplateData", flowSchema);
167
174
  const webSocketGenerateCodeLibs = createWebSocketGenerateCodeLibs(_izContext, flowSchema, saveFilePath)
168
175
  createSourceParams.push(...webSocketGenerateCodeLibs)
169
176
 
@@ -267,13 +274,18 @@ async function generateCodeWithTemplate(_izContext, objSchemaPath) {
267
274
  const externalSqsMainFunction = await createExternalSqsMainFunction(_izContext, flowSchema, saveFilePath);
268
275
  const externalTopicSnsInSqs = createExternalTopicSnsInSqs(_izContext, flowSchema, saveFilePath);
269
276
  const externalTopicSnsOut = createExternalTopicSnsOut(_izContext, flowSchema, saveFilePath);
277
+
278
+ const externalTopicCompleteFunctionYml = createExternalSqsCompleteFunctionYaml(_izContext, flowSchema, saveFilePath);
279
+ const externalTopicCompleteHandler = createExternalSqsCompleteHandler(_izContext, flowSchema, saveFilePath);
280
+ const externalTopicCompleteMainFunction = createExternalSqsCompleteMainFunction(_izContext, flowSchema, saveFilePath);
270
281
  // Group related resources for better organization
271
282
  const externalTopic = [
272
283
  ...externalSqsFunctionYaml,
273
284
  ...externalSqsHandler,
274
285
  ...externalSqsMainFunction,
275
286
  ...externalTopicSnsInSqs,
276
- ...externalTopicSnsOut
287
+ ...externalTopicSnsOut,
288
+ ...externalTopicCompleteFunctionYml, ...externalTopicCompleteHandler, ...externalTopicCompleteMainFunction
277
289
  ];
278
290
 
279
291
  createSourceParams.push(...externalTopic)
@@ -301,14 +313,9 @@ async function generateCodeWithTemplate(_izContext, objSchemaPath) {
301
313
  const flowSchemaOwnTopicQueue = createFlowSchemaOwnTopicQueue(_izContext, flowSchema, saveFilePath);
302
314
  const flowSchemaOwnTopicSnsOut = createFlowSchemaOwnTopicSnsOut(_izContext, flowSchema, saveFilePath);
303
315
 
304
- const flowSchemaOwnTopicFlowStepYml = createFlowScheamOwnTopicFlowStepFunctionYml(_izContext, flowSchema, saveFilePath);
305
- const flowSchemaOwnTopicFlowStepHandler = createFlowSchemaOwnTopicFlowStepHandler(_izContext, flowSchema, saveFilePath);
306
- const flowSchemaOwnTopicFlowStepMainFunction = createFlowScheamOwnTopicFlowStepMainFunction(_izContext, flowSchema, saveFilePath)
307
- const flowSchemaOwnTopicFlowStep = [...flowSchemaOwnTopicFlowStepYml, ...flowSchemaOwnTopicFlowStepHandler, ...flowSchemaOwnTopicFlowStepMainFunction]
308
316
  // Group the resources
309
317
  const ownTopicResources = [
310
- ...flowSchemaOwnTopicComponent, ...flowSchemaOwnTopicEndpointComponent, ...flowSchemaOwnTopicQueue, ...flowSchemaOwnTopicSnsOut, ...flowSchemaOwnTopicFlowStep,
311
- ...flowSchemaOwnTopicEndpointCompleteComponent
318
+ ...flowSchemaOwnTopicComponent, ...flowSchemaOwnTopicEndpointComponent, ...flowSchemaOwnTopicQueue, ...flowSchemaOwnTopicSnsOut, ...flowSchemaOwnTopicEndpointCompleteComponent
312
319
  ];
313
320
 
314
321
 
@@ -328,6 +335,7 @@ async function generateCodeWithTemplate(_izContext, objSchemaPath) {
328
335
  ...flowSchemaEventBridgeFunctionYaml
329
336
  ];
330
337
 
338
+ // console.log("event eventBridge generated", JSON.stringify(eventBridgeResources, null, 2))
331
339
  console.log("event eventBridge generated")
332
340
  createSourceParams.push(...eventBridgeResources);
333
341
  }
@@ -357,7 +365,14 @@ async function generateCodeWithTemplate(_izContext, objSchemaPath) {
357
365
  // createSourceParams.push(...recordCompleteResources);
358
366
  // }
359
367
  }
368
+ const flowSchemaFlowStepYml = createFlowSchemaFlowStepFunctionYaml(_izContext, flowSchema, saveFilePath);
369
+ const flowSchemaFlowStepHandler = createFlowSchemaFlowStepHandler(_izContext, flowSchema, saveFilePath);
370
+ const flowSchemaFlowStepMainFunction = createFlowSchemaFlowStepMainFunction(_izContext, flowSchema, saveFilePath);
371
+ const flowSchemaFlowStepSnsIn = createFlowSchemaFlowStepSnsIn(_izContext, flowSchema, saveFilePath);
372
+ const flowSchemaOwnTopicFlowStep = [...flowSchemaFlowStepYml, ...flowSchemaFlowStepHandler, ...flowSchemaFlowStepMainFunction, ...flowSchemaFlowStepSnsIn]
373
+ createSourceParams.push(...flowSchemaOwnTopicFlowStep)
360
374
  }
375
+
361
376
  if (allLocalFlowSchemas.records.length) {
362
377
  console.log("flowSchema Register");
363
378
  const flowSchemaRegisterHandlerComplete = createFlowSchemaRegisterHandlerComplete(_izContext, saveFilePath);
@@ -385,6 +400,7 @@ async function generateCodeWithTemplate(_izContext, objSchemaPath) {
385
400
  createSourceParams.push(...flowSchemaRegisters);
386
401
  }
387
402
 
403
+ // console.log("createSourceParams flowSchema", createSourceParams)
388
404
  return createSourceParams;
389
405
  } catch (error) {
390
406
  _izContext.logger.error('Error generating code with template flowSchema:', error);
@@ -52,6 +52,7 @@ function data(_izContext, srcPath) {
52
52
  const functionName = upperCase(FUNCTION_NAME.flowSchemaRegister);
53
53
  let functionNameConfig = upperCase(functionName) + upperCase(shortNameHandler(handlerType));
54
54
  let additionalResourcePermission = defaultIamRolePerAction();
55
+
55
56
  additionalResourcePermission.push(
56
57
  createIamRole(
57
58
  {
@@ -8,6 +8,7 @@
8
8
  batchSize: 10
9
9
  filterPatterns: #**** need to update serverless framwork upper v.2.69.1
10
10
  - body: {"MessageAttributes":{"callingFlow":{"Value":["${self:custom.iz_resourcePrefix}<%- functionName %>"]}}} # functionName of callingFlow
11
+ - body: {"MessageAttributes":{"callingFlow":{"Value":[{"exists":false}]}}}
11
12
  role: <%- roleName %>Role
12
13
  #<#<%- functionName %><%- handlerType %>IamRole#>
13
14
  #<#/<%- functionName %><%- handlerType %>IamRole#>
@@ -42,7 +42,6 @@ function data(_izContext, srcPath) {
42
42
  functionName: functionName,
43
43
  handler: HANDLER.hdrSqs,
44
44
  firstLetterUpperCase: upperCase,
45
- roleName: SOURCE_GENERATE_IAM_ROLE.RegisterRole
46
45
  },
47
46
  setting: {
48
47
  savePath: path.join(srcPath, SOURCE_PATH.flowSchemaRegister, 'source/'),
@@ -98,21 +98,20 @@ module.exports.registerCompleteMain = async (
98
98
  objectType: objType.objectType
99
99
  }
100
100
  )
101
-
102
- for (const [fieldName, fieldNameSetting] of Object.entries(objectSchema.fieldNames)) {
103
- if (fieldNameSetting.hasOwnProperty("statusField") && fieldNameSetting.statusField === true) {
104
- if (result.fields[fieldName] !== "complete" && result.fields[fieldName] !== "error") {
105
- // if status is not complete or error will save data into table
106
- await dynamodbSharedLib.putItem(_izContext,
107
- await dynamodbSharedLib.tableName(_izContext, "RegisterRecords"),
108
- {
109
- identifiersTask: requestParams.identifiersTask,
110
- connectionId: connectionId
111
- }
112
- )
113
- } else {
114
- if (!result) {
115
- await generatedCodeLibs.postToConnection({ message: "not have record" }, connectionId)
101
+ if (!result) {
102
+ await generatedCodeLibs.postToConnection({ message: "not have record" }, connectionId)
103
+ } else {
104
+ for (const [fieldName, fieldNameSetting] of Object.entries(objectSchema.fieldNames)) {
105
+ if (fieldNameSetting.hasOwnProperty("statusField") && fieldNameSetting.statusField === true) {
106
+ if (result.fields[fieldName] !== "complete" && result.fields[fieldName] !== "error") {
107
+ // if status is not complete or error will save data into table
108
+ await dynamodbSharedLib.putItem(_izContext,
109
+ await dynamodbSharedLib.tableName(_izContext, "RegisterRecords"),
110
+ {
111
+ identifiersTask: requestParams.identifiersTask,
112
+ connectionId: connectionId
113
+ }
114
+ )
116
115
  } else {
117
116
  await generatedCodeLibs.postToConnection({ message: result }, connectionId)
118
117
  }
@@ -120,7 +119,6 @@ module.exports.registerCompleteMain = async (
120
119
  }
121
120
  }
122
121
  }
123
-
124
122
  // check statusType
125
123
  switch (flowSchema.statusType) {
126
124
  case "statusField":
@@ -156,12 +154,13 @@ module.exports.registerCompleteMain = async (
156
154
  await Promise.all(tasks.Items.map(async (task) => {
157
155
  await generatedCodeLibs.postToConnection({ message: task }, task.connectionId)
158
156
  }))
157
+ await generatedCodeLibs.postToConnection({ message: tasks.Items[0] }, connectionId)
159
158
  } else {
160
159
  await dynamodbSharedLib.putItem(_izContext,
161
160
  await dynamodbSharedLib.tableName(_izContext, "RegisterRecords"),
162
161
  {
163
162
  identifiersTask: hash(identifier),
164
- connecttionId: connectionId
163
+ connectionId: connectionId
165
164
  }
166
165
  )
167
166
  }
@@ -32,29 +32,12 @@ const { SOURCE_PATH, SAVE_FILE_NAME, FUNCTION_NAME, defaultIamRolePerAction, DYN
32
32
  const createRegisterTable = (_izContext, srcPath) => {
33
33
  let additionalResourcePermission = defaultIamRolePerAction();
34
34
  const tableName = "RegisterRecords";
35
- additionalResourcePermission.push(
36
- createIamRole(
37
- {
38
- [RESOURCE_CLASSES.dynamoDbTable]: [
39
- DYNAMO_RESOURCE.putItem,
40
- DYNAMO_RESOURCE.getItem,
41
- DYNAMO_RESOURCE.query,
42
- DYNAMO_RESOURCE.deleteItem,
43
- DYNAMO_RESOURCE.updateItem
44
- ]
45
- },
46
- [
47
- resourceNames(RESOURCE_CLASSES.dynamoDbTable, tableName)
48
- ]
49
- ),
50
- );
51
35
 
52
36
  return [{
53
37
  templatePath: templatePath,
54
38
  templateData: {
55
39
  tableName: tableName,
56
40
  resourceName: tableName,
57
- roleName: SOURCE_GENERATE_IAM_ROLE.RegisterRole,
58
41
  additionalResourcePermission,
59
42
  attributes: [
60
43
  {
@@ -50,7 +50,6 @@ function createDataForSnsIn(_izContext, srcPath) {
50
50
  templateData: {
51
51
  queueName: upperCase(FUNCTION_NAME.flowSchemaRegister),
52
52
  firstLetterUpperCase: upperCase,
53
- roleName: SOURCE_GENERATE_IAM_ROLE.RegisterRole,
54
53
  },
55
54
  setting: {
56
55
  initialData: "Resources:\n",
@@ -56,9 +56,7 @@ function createDataForSubscriptionOutAll(_izContext, allLocalFlowSchemas, srcPat
56
56
  }
57
57
  let queueName;
58
58
  if (flowSchema.outputTopic) {
59
- let flowStepOut = Object.keys(flowSchema.flowSteps)[1].split("_")
60
- // queueName = flowStepOut[3] + flowStepOut[2]
61
- queueName = flowStepOut[0] + flowSchema.flowTag + "Complete";
59
+ queueName = upperCase(flowSchema.flowTag);
62
60
  }
63
61
 
64
62
  if (queueName) {
@@ -1,8 +1,8 @@
1
1
  ##===== [Topic In]
2
- Subscription<%- queueName %>:
2
+ SubscriptionOut<%- queueName %>:
3
3
  Type: AWS::SNS::Subscription
4
4
  Properties:
5
- TopicArn: !Ref <%- queueName %>
5
+ TopicArn: !Ref Out<%- queueName %>
6
6
  Endpoint: "arn:aws:sqs:${self:custom.iz_region}:${self:custom.iz_accountId}:${self:custom.iz_resourcePrefix}<%- endpoint %>"
7
7
  Protocol: "sqs"
8
8
  <%_ function firstLetterUpperCase(text){
@@ -91,35 +91,6 @@ async function data(_izContext, allLocalFlowSchemas, srcPath) {
91
91
  )
92
92
  )
93
93
 
94
- let tableStoredCacheList = new Set();
95
- await Promise.all(allLocalFlowSchemas.records.map(async (flowSchema) => {
96
- if (flowSchema.statusType === "storedCache") {
97
- let objectSchema = await getLocalObjectSchemas(_izContext, [flowSchema.objType.objectType], path.join(srcPath, "./schemas")).then(res => res.records[0]);
98
- for (const storageResource of Object.values(objectSchema.storageResources)) {
99
- if (storageResource.storageType === STORAGE_TYPES.dynamoDB) {
100
- tableStoredCacheList.add(storageResource.tableName);
101
- }
102
- }
103
- }
104
- }))
105
- if (tableStoredCacheList.size > 0) {
106
- let tableNames = [...tableStoredCacheList]
107
- additionalResourcePermission.push(
108
- createIamRole(
109
- {
110
- [RESOURCE_CLASSES.dynamoDbTable]: [
111
- DYNAMO_RESOURCE.getItem,
112
- // DYNAMO_RESOURCE.putItem,
113
- // DYNAMO_RESOURCE.query,
114
- // DYNAMO_RESOURCE.deleteItem,
115
- // DYNAMO_RESOURCE.updateItem
116
- ]
117
- },
118
- tableNames.map(tableName => resourceNames(RESOURCE_CLASSES.dynamoDbTable, tableName))
119
- )
120
- )
121
- }
122
-
123
94
  return [{
124
95
  templatePath: templatePath,
125
96
  templateData: {
@@ -50,7 +50,6 @@ function createParamsForCreateSource(_izContext, srcPath) {
50
50
  isAsync,
51
51
  functionName: functionName,
52
52
  firstLetterUpperCase: upperCase,
53
- roleName: SOURCE_GENERATE_IAM_ROLE.RegisterRole,
54
53
  routeName: FUNCTION_NAME.flowSchemaRegister,
55
54
  },
56
55
  setting: {
@@ -65,11 +65,6 @@ module.exports.main = middlewareHandler.wrap(async (event, context, callback) =>
65
65
  //(<additionalParams>)
66
66
  //(</additionalParams>)
67
67
  )
68
- await postToConnection(
69
- { message: result },
70
- connectionId
71
- )
72
- return (izara.response.webSocketSuccess());
73
68
  break
74
69
  }
75
70
  } else {
@@ -89,20 +89,20 @@ module.exports.registerMain = async (
89
89
  }
90
90
  )
91
91
 
92
- for (const [fieldName, fieldNameSetting] of Object.entries(objectSchema.fieldNames)) {
93
- if (fieldNameSetting.hasOwnProperty("statusField") && fieldNameSetting.statusField === true) {
94
- if (result.fields[fieldName] !== "complete" && result.fields[fieldName] !== "error") {
95
- // if status is not complete or error will save data into table
96
- await dynamodbSharedLib.putItem(_izContext,
97
- await dynamodbSharedLib.tableName(_izContext, "RegisterRecords"),
98
- {
99
- identifiersTask: requestParams.identifiersTask,
100
- connectionId: connectionId
101
- }
102
- )
103
- } else {
104
- if (!result) {
105
- await generatedCodeLibs.postToConnection({ message: "not have record" }, connectionId)
92
+ if (!result) {
93
+ await generatedCodeLibs.postToConnection({ message: "not have record" }, connectionId)
94
+ } else {
95
+ for (const [fieldName, fieldNameSetting] of Object.entries(objectSchema.fieldNames)) {
96
+ if (fieldNameSetting.hasOwnProperty("statusField") && fieldNameSetting.statusField === true) {
97
+ if (result.fields[fieldName] !== "complete" && result.fields[fieldName] !== "error") {
98
+ // if status is not complete or error will save data into table
99
+ await dynamodbSharedLib.putItem(_izContext,
100
+ await dynamodbSharedLib.tableName(_izContext, "RegisterRecords"),
101
+ {
102
+ identifiersTask: requestParams.identifiersTask,
103
+ connectionId: connectionId
104
+ }
105
+ )
106
106
  } else {
107
107
  await generatedCodeLibs.postToConnection({ message: result }, connectionId)
108
108
  }
@@ -110,7 +110,6 @@ module.exports.registerMain = async (
110
110
  }
111
111
  }
112
112
  }
113
-
114
113
  // Initialize storedCacheData variable that will be used in multiple switch cases
115
114
  switch (flowSchema.statusType) {
116
115
  case "statusField":
@@ -143,6 +142,8 @@ module.exports.registerMain = async (
143
142
  await Promise.all(tasks.Items.map(async (task) => {
144
143
  await generatedCodeLibs.postToConnection({ message: task }, task.connectionId)
145
144
  }))
145
+ await generatedCodeLibs.postToConnection({ message: tasks.Items[0] }, connectionId)
146
+ return tasks.Items[0]
146
147
  } else {
147
148
  await dynamodbSharedLib.putItem(_izContext,
148
149
  await dynamodbSharedLib.tableName(_izContext, "RegisterRecords"),
@@ -1,6 +1,6 @@
1
1
  let [triggerCacheStatus, triggerCache] = await triggeredCacheSharedLib.checkTriggeredCache(
2
2
  _izContext,
3
- <%- tableName %>,
3
+ "<%- tableName %>",
4
4
  {
5
5
  //(<keyValueTriggerCacheTable>)
6
6
  //(</keyValueTriggerCacheTable>)
@@ -17,4 +17,10 @@ if (triggerCacheStatus !== "process") {
17
17
  //(<afterValidateTriggerCacheStatus>)
18
18
  //(</afterValidateTriggerCacheStatus>)
19
19
  }
20
+
21
+
22
+ return {
23
+ //(<validateTriggerCacheProcessing>)
24
+ //(</validateTriggerCacheProcessing>)
25
+ }
20
26
  }
@@ -95,7 +95,7 @@ function createSourceParams(_izContext, allLocalFlowSchemas, srcPath) {
95
95
  {
96
96
  [RESOURCE_CLASSES.sns]: [SNS_RESOURCE.subscribe]
97
97
  },
98
- allLocalFlowSchemas.records.map(flowSchema => resourceNames(RESOURCE_CLASSES.sns, flowSchema.flowTag + "Complete_Out"))
98
+ allLocalFlowSchemas.records.map(flowSchema => resourceNames(RESOURCE_CLASSES.sns, flowSchema.flowTag + "_Out"))
99
99
  )
100
100
  )
101
101
 
@@ -4,10 +4,11 @@
4
4
  name: ${self:custom.iz_resourcePrefix}<%- firstLetterUpperCase(functionName) %><%- firstLetterUpperCase(handlerType) %>
5
5
  events:
6
6
  - sqs:
7
- arn: arn:aws:sqs:${self:custom.iz_region}:${self:custom.iz_accountId}:${self:custom.iz_resourcePrefix}<%- queueName %> + <%- handlerType %>
7
+ arn: arn:aws:sqs:${self:custom.iz_region}:${self:custom.iz_accountId}:${self:custom.iz_resourcePrefix}<%- queueName %>
8
8
  batchSize: 10
9
9
  filterPatterns: #**** need to update serverless framwork upper v.2.69.1
10
10
  - body: {"MessageAttributes":{"callingFlow":{"Value":["${self:custom.iz_resourcePrefix}<%- functionName %>"]}}} # functionName of callingFlow
11
+ - body: {"MessageAttributes":{"callingFlow":{"Value":[{"exists":false}]}}}
11
12
  role: <%- roleName %>Role
12
13
  #<#<%- functionName %><%- handlerType %>IamRole#>
13
14
  #<#/<%- functionName %><%- handlerType %>IamRole#>
@@ -0,0 +1,97 @@
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
+
20
+ const path = require("path")
21
+
22
+
23
+ // const {
24
+ // HANDLER,
25
+ // STORAGE_TYPES
26
+ // } = require('@izara_project/izara-core-library-service-schemas/src/Consts');
27
+
28
+ const { firstLetterLowerCase: lowerCase, firstLetterUpperCase: upperCase } = require("../../../../../MainLibs/src/Utils.js");
29
+ const STORAGE_TYPES = {
30
+ dynamoDB: "dynamoDB",
31
+ graph: "graph"
32
+ }
33
+
34
+ const templatePath = path.join(__dirname, './template.ejs');
35
+
36
+
37
+ const { SOURCE_PATH, SAVE_FILE_NAME, FUNCTION_NAME, HANDLER } = require('../../../../../MainLibs/src/Consts.js');
38
+
39
+ /**
40
+ * create data for dynamoDbYaml tempalte from objectSchema
41
+ * return array of dynamoDb data
42
+ * because one objectSchema can create multiple dynamoDb table
43
+ *
44
+ * @param {Object} _izContext
45
+ * @param {String} saveFilePath
46
+ * @returns {Object[]} - data of multiple dynamoDb template
47
+ */
48
+
49
+ function createDataForDefaultSnsInSqs(_izContext, allFlowSchema, srcPath) {
50
+ let resultsForCreateDefaultSnsInSqs = [];
51
+ let defaultDsqQueueDataList = [];
52
+ for (const flowSchema of allFlowSchema.records) {
53
+ if (flowSchema.hasOwnProperty("flowSteps")) {
54
+
55
+ let flowSteps = Object.keys(flowSchema.flowSteps);
56
+ if (flowSteps.length && flowSteps.length > 0) {
57
+ // console.log("create topic by flowSteps", flowSteps)
58
+
59
+
60
+
61
+ if (flowSchema.outputTopic) {
62
+ if (flowSteps.includes("Out")) {
63
+ if (flowSchema.outputTopic) {
64
+ let topicOut = `${upperCase(flowSchema.flowTag)}`;
65
+ defaultDsqQueueDataList.push({
66
+ queueName: `WebSocketComplete` + upperCase(HANDLER.hdrSqs),
67
+ subscribeTo: topicOut
68
+ }
69
+ )
70
+
71
+ }
72
+ }
73
+ }
74
+ }
75
+ }
76
+ }
77
+
78
+ if (defaultDsqQueueDataList.length) {
79
+ for (let defaultDsqQueueData of defaultDsqQueueDataList) {
80
+ resultsForCreateDefaultSnsInSqs.push({
81
+ templatePath: templatePath,
82
+ templateData: defaultDsqQueueData,
83
+ setting: {
84
+ initialData: "Resources:\n",
85
+ savePath: path.join(srcPath, SOURCE_PATH.resourceYaml),
86
+ saveFileName: SAVE_FILE_NAME.snsInSqsYaml,
87
+ fileExtension: ".yml",
88
+ isAppend: true
89
+ }
90
+ })
91
+ }
92
+ }
93
+
94
+ return resultsForCreateDefaultSnsInSqs;
95
+ }
96
+
97
+ module.exports = createDataForDefaultSnsInSqs;
@@ -0,0 +1,52 @@
1
+ <% if (subscribeTo) { %>
2
+ ##===== SNS Subscription
3
+ SubscriptionToOut<%- subscribeTo %>:
4
+ Type: AWS::SNS::Subscription
5
+ Properties:
6
+ TopicArn: !Ref Out<%- subscribeTo %>
7
+ Endpoint: "arn:aws:sqs:${self:custom.iz_region}:${self:custom.iz_accountId}:${self:custom.iz_resourcePrefix}<%- queueName %>"
8
+ Protocol: "sqs"
9
+ <% } %>
10
+ #------- queue ---------
11
+ <%- queueName %>:
12
+ Type: "AWS::SQS::Queue"
13
+ Properties:
14
+ QueueName: ${self:custom.iz_resourcePrefix}<%- queueName %>
15
+ RedrivePolicy:
16
+ deadLetterTargetArn: #!GetAtt
17
+ Fn::GetAtt:
18
+ - <%- queueName %>DLQ
19
+ - Arn
20
+ maxReceiveCount: 3
21
+ VisibilityTimeout: 120
22
+
23
+ <%- queueName %>DLQ:
24
+ Type: AWS::SQS::Queue
25
+ Properties:
26
+ QueueName: ${self:custom.iz_resourcePrefix}<%- queueName %>DLQ
27
+
28
+ <%- queueName %>Policy:
29
+ Type: AWS::SQS::QueuePolicy
30
+ Properties:
31
+ PolicyDocument:
32
+ Version: "2012-10-17"
33
+ Statement:
34
+ - Sid: "allow-sns-messages"
35
+ Effect: Allow
36
+ Principal: "*"
37
+ Resource: #!GetAtt
38
+ Fn::GetAtt:
39
+ - <%- queueName %>
40
+ - Arn
41
+ Action: "SQS:SendMessage"
42
+ Queues:
43
+ - Ref: <%- queueName %>
44
+ #<#<%- firstLetterUpperCase(queueName) %>QueueSetting#>
45
+ #<#/<%- firstLetterUpperCase(queueName) %>QueueSetting#>
46
+
47
+ <%_ function firstLetterUpperCase(text){
48
+ return text.charAt(0).toUpperCase() + text.slice(1)
49
+ } _%>
50
+ <%_ function firstLetterLowerCase(str) {
51
+ return str.charAt(0).toLowerCase() + str.slice(1)
52
+ } _%>
@@ -8,6 +8,7 @@
8
8
  batchSize: 10
9
9
  filterPatterns: #**** need to update serverless framwork upper v.2.69.1
10
10
  - body: {"MessageAttributes":{"callingFlow":{"Value":["${self:custom.iz_resourcePrefix}<%-firstLetterUpperCase(functionName) %>"]}}} # functionName of callingFlow
11
+ - body: {"MessageAttributes":{"callingFlow":{"Value":[{"exists":false}]}}}
11
12
  role: <%- roleName %>Role
12
13
  #<#<%- functionName %><%- handlerType %>IamRole#>
13
14
  #<#/<%- functionName %><%- handlerType %>IamRole#>
@@ -8,6 +8,7 @@
8
8
  batchSize: 10
9
9
  filterPatterns: #**** need to update serverless framwork upper v.2.69.1
10
10
  - body: {"MessageAttributes":{"callingFlow":{"Value":["${self:custom.iz_resourcePrefix}<%-firstLetterUpperCase(functionName) %>"]}}} # functionName of callingFlow
11
+ - body: {"MessageAttributes":{"callingFlow":{"Value":[{"exists":false}]}}}
11
12
  role: <%- roleName %>Role
12
13
  #<#<%- functionName %><%- handlerType %>IamRole#>
13
14
  #<#/<%- functionName %><%- handlerType %>IamRole#>
@@ -8,6 +8,7 @@
8
8
  batchSize: 10
9
9
  filterPatterns: #**** need to update serverless framwork upper v.2.69.1
10
10
  - body: {"MessageAttributes":{"callingFlow":{"Value":["${self:custom.iz_resourcePrefix}<%-firstLetterUpperCase(functionName) %>"]}}} # functionName of callingFlow
11
+ - body: {"MessageAttributes":{"callingFlow":{"Value":[{"exists":false}]}}}
11
12
  role: <%- roleName %>Role
12
13
  #<#<%- functionName %><%- handlerType %>IamRole#>
13
14
  #<#/<%- functionName %><%- handlerType %>IamRole#>